Hey Guys,
I just posted my first issue, and here is my 2nd issue:
I am having a problem with stopping a sprites action half-way-through animating, it appears to me that if the sprite is animating a Sequence, you cant stop it.
As you can see from my below code, i have tried: [SpriteAtlas stopActionByTag:actionTag], [SpriteAtlas stopAction:lastAction], [SpriteAtlas stopAllActions]
None of these will stop the animation at all.
Code:
if (lastDir == 0) {
[rightSprite stopActionByTag:actionTag];
//[rightSprite stopAllActions];
//[rightSprite stopAction:lastAction];
} else if (lastDir == 1) {
[leftSprite stopActionByTag:actionTag];
//[leftSprite stopAllActions];
//[leftSprite stopAction:lastAction];
} else if (lastDir == 2) {
[upSprite stopActionByTag:actionTag];
//[upSprite stopAllActions];
//[upSprite stopAction:lastAction];
} else if (lastDir == 3) {
[downSprite stopActionByTag:actionTag];
//[downSprite stopAllActions];
//[downSprite stopAction:lastAction];
}
if (lastDir == 0 || lastDir == 1 || lastDir == 2 || lastDir == 3) [lastAction release];
AtlasAnimation *animation = [AtlasAnimation animationWithName:@"move" delay:0.05f];
for(int i=0; i < 10; i++) {
[animation addFrameWithRect:CGRectMake((tiltDir + 1)*32, i*32, 32, 32)];
}
lastAction = [[Sequence actions:[Animate actionWithAnimation:animation], [CallFunc actionWithTarget:self selector:@selector(resetSpriteToIdle)], nil] retain];
//lastAction = [Sequence actions:[Animate actionWithAnimation:animation], [CallFunc actionWithTarget:self selector:@selector(resetSpriteToIdle)], nil];
[lastAction setTag:actionTag];
if (tiltDir == 0) {
[rightSprite runAction:lastAction];
} else if (tiltDir == 1) {
[leftSprite runAction:lastAction];
} else if (tiltDir == 2) {
[upSprite runAction:lastAction];
} else if (tiltDir == 3) {
[downSprite runAction:lastAction];
}
lastDir = tiltDir;
Thanks for your help.