したがって、ここでの問題は、アニメーション化された発射体を1つ作成するときに、すべてが正常であるということです。ユーザーが秒を作成するとすぐに、最初のアニメーションは停止します。
了解しました。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]];
次に、ユーザーが画面をタップしたときに呼び出される私のcreate bulletsメソッドで、次のようにします。
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回目は、アニメーション化された弾丸が作成されますが、既存の弾丸はアニメーション化を停止します。