I want to move objects from left to right on the screen for an unlimited time. I can move one object with this code. What I want is that every second a new instance of this object start moving from the left. So at first I see one object moving. The next second I see 2 objects moving. In a couple of seconds I want to see objects moving from left to right. How to achieve this? Am I on the right track?
timer1 = new Timer();
timer1.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
TimerMethod();
}
}, 1000, 2000);
private void TimerMethod()
{
this.runOnUiThread(Timer_Tick);
}
private Runnable Timer_Tick = new Runnable() {
public void run() {
moveAnimation();
}
};
public void moveAnimation() {
//the actual animation
move = new TranslateAnimation(0, 500, 0, 0);
move.setDuration(2000);
move.setFillAfter(true);
move.setAnimationListener(new AnimationListener(){
@Override
public void onAnimationEnd(Animation arg0) {
}
@Override
public void onAnimationRepeat(Animation arg0) { }
@Override
public void onAnimationStart(Animation arg0) { }
});
}
As no one answered I am just telling that I started learning AndEngine and I managed to create new instances of an object appear and move from anywhere outside the screen to anywhere inside the screen in random director and at random velocity, which is far more than I wanted to achieve first.
If anyone wants to learn AndEngine, you find the tutorials here. I also suggest to download the AndEngine app from the market to see what this engine is capable of.