1
ここで問題となるのは、アニメーションされた1つの発射物を作成するときです。ユーザーが秒を作成すると、最初にアニメーションが停止します。Cocos2D - 2番目のスプライトをアニメーション化すると、最初にアニメーションが停止します
よしが、ここで私は私のinitでそれを設定してい方法は次のとおりです。ユーザーは、画面をタップしたときに呼び出される私の作成弾丸の方法では、
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:
@"acorns.plist"];
CCSpriteBatchNode *spriteSheet = [CCSpriteBatchNode
batchNodeWithFile:@"acorns.png"];
[self addChild:spriteSheet];
NSMutableArray *flyingFrames = [NSMutableArray array];
for(int i = 1; i <= 4; ++i) {
[flyingFrames addObject:
[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:
[NSString stringWithFormat:@"acorn%d.png", i]]];
}
CCAnimation *flying = [CCAnimation
animationWithFrames:flyingFrames delay:0.5f];
self.flying = [CCRepeatForever actionWithAction:
[CCAnimate actionWithAnimation:flying restoreOriginalFrame:NO]];
その後、私が行います
CCSprite *bullet = [CCSprite spriteWithSpriteFrameName:@"acorn1.png"];
bullet.position = CGPointMake(140.0f, FLOOR_HEIGHT+145.0f);
[bullet runAction:_flying];
[self addChild:bullet z:9];
[bullets addObject:bullet];
初めてユーザーがタップすると、すべて正常に動作します。 2回目は、アニメートされた箇条書きが作成されますが、既存のアニメーションはアニメートされなくなります。