2012-11-29 26 views
0

我有一个CCSpriteSheet和一个CCSpriteBatchNode,它可以完美地运行.png和.plist文件,但是,有什么办法可以知道在哪个帧中可以启动另一个CCAction?动画过程中的CCSprite帧编号

例如,我有一个30帧的CCAnimation,当动画在第15帧时,我想动画另一个精灵。这是可能的吗?

在此先感谢。

+0

不知道。但在你的例子中,你可以通过调度一个方法来完成。基本上,如果你的动画每帧延迟0.05,那么你应该安排一个方法在(0.05 * 15)之后触发。这种方法执行其他动画。 – Voldemort

回答

0

我通常从我的游戏之一满足这种需要的是这样的代码片段:

float stall; 
CCAnimation *secondAnim; 
CCSprite *secondSprite; 
NSString *dyingFx; 
id sound = (self.alive ? [GENoopAction action] : 
         [GEPlayFx actionWithSoundFile:dyingFx] 
      ); 

id second = [CCSequence actions: 
     [CCDelayTime actionWithDuration:stall] 
     , [CCShow action] 
     , sound 
     , [CCAnimate actionWithAnimation:secondAnim] 
     , [CCCallFunc actionWithTarget:self selector:@selector(hurtComplete)] 
]; 
secondSprite.visible= NO; 
[secondSprite runAction:second]; 

GEPlayFx和GENoopAction玩具是我为自己(CCActionInstant实现)创建的。

2

将动画拆分为多个部分并使用CCSequence。例如:

CCAction *Action = [CCSequence actions: 
         [CCAnimate actionWithAnimation:myCCanimationPart1], 
         [CCCallBlock actionWithBlock:^ 
         { 
          [myOtherSprite runAction:(otherAnimationAction)]; 
         }], 
         [CCAnimate actionWithAnimation:myCCanimationPart2], 
         nil]; 
+0

这是我最初的方法,也是我最终呈现给客户的解决方案。 – Rotten