Reputation: 77596
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();
}
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
Upvotes: 2
Views: 1904
Reputation: 40336
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.
Upvotes: 1