Cocoa touch 精灵动画cocos2d

Cocoa touch 精灵动画cocos2d,cocoa-touch,animation,cocos2d-iphone,Cocoa Touch,Animation,Cocos2d Iphone,我怎样才能给这个精灵设置动画 if ((self = [super initWithSpriteFrameName:@"Boss_ship_5.png" world:world shapeName:@"Boss_ship" maxHp:50 healthBarType:HealthBarTypeRed])) { 我试着用这个,但用_层不行 CCSpriteFrameCache * cache = [CCSpriteFrameCache sharedSpriteFrameCache]; CCA

我怎样才能给这个精灵设置动画

if ((self = [super initWithSpriteFrameName:@"Boss_ship_5.png" world:world shapeName:@"Boss_ship" maxHp:50 healthBarType:HealthBarTypeRed])) {
我试着用这个,但用_层不行

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]]];

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


另外,
CCAnimation
操作应该与
CCSprites
一起使用。哪个类是
\u layer
对象?

Bossship2是一个实现@implementation Bossship2{ActionLayer*\u层;我想为Boss船精灵制作动画,我刚刚使用了我发布的方法,但是使用了gameobjet*船。