所以这里的问题是当我创建一个动画弹丸时,一切都很好。一旦用户创建了第二个,第一个就停止动画。
好的,这就是我在初始化中的设置方式:
[[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];
因此,用户第一次点击时,一切正常。第二次,创建了一个动画子弹,但现有的子弹停止动画,依此类推。