public void MoveMyButton (int x) //where the button suppose to move to
{
TranslateAnimation anim=new TranslateAnimation(this.getLeft() ,x, this.getTop() ,20));
anim.setFillAfter(true);
anim.setDuration(1000);
this.setAnimation(anim);
anim.start();
}
- button’s x at start is 1.
- I call the method to move it to 100, and it goes from 1 to 100
- I call it to go to 200, and it goes from 1 to 200, instead of 100 to 200
Is there any way to make the animation to save the location of the button as it animates it?
Thanks
_____________________________UPDATE__________________________________
Please correct me if i am wrong.
An animation set is to combine multiple animations, so move from position 1 to position 2
and then from position 2 to position 3.
The problem is that my animations are not predictable. My application is a multiplayer game which 10 players play together.
Every time a player gets a turn the timer button should move toward that player. then when another player gets a turn the button suppose to move from the previous player to the new player.
So I have to show animations when i receive messages from the server. example:
– Move the button from current position to player 1
– Move the button from player 1 to player 3
– Move the button from player 3 to player 9
– ……….. etc
As you can see i can’t predict where the button is suppose to go.
I hope i explained well enough (The youtube link i posted above is exactly what i am trying to achieve)
Any new suggestions?
Thanks for the replies
If I’m understanding correctly, I think you need to move the button to the intermediate location before invoking the animation a second time.
Update: Or you could use an AnimationSet which contains two TranslateAnimations within it to get the job done.