-2

在我的游戏中,我正在运行两个动画,CCSpawn但它一次只显示一个动画。这里有什么问题?这是我的代码。

[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"walkcycle.plist"] ;
CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"walkcycle.png"];
[heroWorldLayer addChild:spriteSheet];

NSMutableArray *runFrames = [NSMutableArray array];
for(int i = 1; i <= 11; ++i) {
    CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"Run_Anim00%02d.png", i]];
    [runFrames addObject:frame];
}
id runAnim = [CCAnimation animationWithFrames:runFrames delay:1.0/22.0];
id runAnimate = [CCAnimate actionWithAnimation:runAnim restoreOriginalFrame:NO];
//    _runAction = [CCRepeatForever actionWithAction:runAnimate];
//    [heroBodySprite runAction:_runAction];

NSMutableArray *poofFrames = [NSMutableArray array];
for(int i = 1; i <= 10; ++i) {
    CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"Poof00%02d.png", i]];
    [poofFrames addObject:frame];
}
id poofAnim = [CCAnimation animationWithFrames:poofFrames delay:1.0/20.0];
id poofAnimate = [CCAnimate actionWithAnimation:poofAnim restoreOriginalFrame:NO];
//    id poofAction = [CCRepeatForever actionWithAction:poofAnimate];
//    [heroBodySprite runAction:poofAction];

[heroBodySprite runAction:[CCRepeatForever actionWithAction:[CCSpawn actions:runAnimate, poofAnimate, nil]]];
4

1 回答 1

0

你基本上想在同一个精灵上同时显示两个不同的帧。这是不可能的,想想吧。你期待 Cocos2d 为你带来怎样的神奇?有些动画只是不能相互兼容。这就像如果你试图同时向左和向右移动一个精灵,但很惊讶它没有工作......

于 2013-05-28T14:39:30.680 回答