I want to run an animation "up animation" on a sprite when moved upward and "down animation" when moved downward. this is how i am trying to do it:
////////////////// MOVEMENTS /////////////
-(void)moveTo:(CGPoint)location
{
if(self.position.y!=location.y)
{
if(self.position.y<location.y) //going down
{
Animation *anim=[self animationByName:@"up"];
Action *action=[Animate actionWithAnimation: anim];
if(!action.isRunning)//imaginary
[self runAction:action];
}
else
{
Animation *anim=[self animationByName:@"down"];
Action *action=[Animate actionWithAnimation: anim];
if(!action.isRunning)//imaginary
[self runAction:action];
}
self.position= location;
}
}
so is there any function like "isRunning" so that already running animation gets completed before it is scheduled again.