开发者

iphone cocos2d CCSequence of Action and CCParticleSystem animation

开发者 https://www.devze.com 2023-04-05 00:59 出处:网络
I´m new to Cocos2d. I´m trying to run two animations one after another. The first one is: CCAction *walkAction;

I´m new to Cocos2d. I´m trying to run two animations one after another. The first one is:

CCAction *walkAction;
CCAnimation *walkAnim = [CCAnimation 
                         animationWithFrames:walkAnimFrames delay:0.15f];
bear = [CCSprite spriteWithSpriteFrameName:@"normal1.png"];        
walkAction =   [CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO];
[bear runAction:walkAction];
[spriteSheet addChild:bear];

The second which I want to fire right after the first one is:

     CCParticleSystem *killPigAnim = [CCParticleS开发者_运维技巧ystemPoint particleWithFile:@"killPigAnim.plist"];
     [self addChild:killPigAnim];

How can I achive that when the second one is not an action but the CCParticleSystem object.


You can use the action CCCallFunc to either call the start method on the particle system or call a method in your class which starts the particle system.

i.e.

-(void) startParticles
{
    //Start your particles
}


-(void) myOtherMethod
{
    ...
    walkAction =   [CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO];
    CCCallFunc *callAction = [CCCallFunc actionWithTarget:self selector:@selector(startParticles)];
    [bear runAction:[CCSequence actionWithActions:walkAction, callAction, nil];
    ...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消