Reputation: 779
I am trying to run an animation on a sprite each time a button is pressed.
But for some reason, the action is only ran once and wont run again like i need it to.
Here is my action if it helps.My action is declared as an id instance variable.
moveUp = [CCMoveTo actionWithDuration:3 position:ccp(60,self.position.y+200)];
Upvotes: 0
Views: 290
Reputation: 64478
Are you trying to re-use the same action? Like so:
moveUp = [CCMoveTo actionWithDuration:3 position:ccp(60,self.position.y+200)];
[self runAction:moveUp];
// some time later …
[self runAction:moveUp];
Then this won't work. You have to create a new action every time, like so:
CCAction* moveUp = [CCMoveTo actionWithDuration:3 position:ccp(60,self.position.y+200)];
[self runAction:moveUp];
// some time later …
CCAction* moveUp = [CCMoveTo actionWithDuration:3 position:ccp(60,self.position.y+200)];
[self runAction:moveUp];
Upvotes: 1