我有一个使用两个 png 的动画精灵。动画效果很好。我有另一种在游戏结束时运行的方法。
//Grey mouse with Pompom
greyMousePomPom = [CCSprite spriteWithFile:@"pink_mice_pom_anime_01.png"];
greyMousePomPom.tag=132;
[self addChild:greyMousePomPom z:6];
greyMousePomPom.position = CGPointMake(550, 70);
//Grey Pom Pom Mouse animation
CCAnimation *greyMousePomPomAnimate = [CCAnimation animation];
[greyMousePomPomAnimate addFrameWithFilename:@"gray_mice_pom_anime_01.png"];
[greyMousePomPomAnimate addFrameWithFilename:@"gray_mice_pom_anime_02.png"];
id greyMousePopPomAnimationAction = [CCAnimate actionWithDuration:1.3f animation:greyMousePomPomAnimate restoreOriginalFrame:NO];
repeatAnimationPomPom2 = [CCRepeatForever actionWithAction:greyMousePopPomAnimationAction];
[greyMousePomPom runAction:repeatAnimationPomPom2];
当我运行我的方法来更改动画精灵纹理并停止它们时,动画会在新纹理后面继续。
-(void) changePomPomMiceToSadFaceForFreeFall
{ NSLog(@"让老鼠伤心");
[self stopAllActions];
[greyMousePomPom setTexture:[[CCTextureCache sharedTextureCache] addImage:@"gray_mice_pom_anime_03.png"]];
}
我知道这种方法有效,因为它是 NSLogging 并且纹理正在发生变化。但是为什么动画没有停止?我试图通过标签和声明动作来删除它,但没有成功。
我知道有很多人比我聪明..你能帮忙吗?