精灵动画cocos2d



我如何使这个精灵动画?

if ((self = [super initWithSpriteFrameName:@"Boss_ship_5.png" world:world shapeName:@"Boss_ship" maxHp:50 healthBarType:HealthBarTypeRed])) {

我正在尝试这个,但与_layer不工作…

CCSpriteFrameCache * cache =
[CCSpriteFrameCache sharedSpriteFrameCache];
CCAnimation *animation = [CCAnimation animation];
[animation addSpriteFrame:
    [cache spriteFrameByName:@"Boss_ship_5.png"]];
[animation addSpriteFrame:
    [cache spriteFrameByName:@"Boss_ship_4.png"]];
animation.delayPerUnit = 0.05;
[_layer runAction:
    [CCRepeatForever actionWithAction:
        [CCAnimate actionWithAnimation:animation]]];

在向animation对象添加精灵之前,您需要将纹理加载到CCSpriteFrameCache中。请看一看

http://www.cocos2d-iphone.org/archives/633

另外,CCAnimation的动作应该与CCSprites一起使用。哪个类是_layer对象?

最新更新