1
애니메이션 화 된 하나의 탄환을 만들면 문제가 해결됩니다. 사용자가 초를 만들면 첫 번째 애니메이션이 멈 춥니 다.Cocos2D - 두 번째 스프라이트에 애니메이션을 적용하면 애니메이션이 멈 춥니 다.
좋아가 여기 내 초기화에서 그것을하고 있어요 방법 : 사용자가 화면을 탭 때 호출되는 내 생성 총알 방법에
[[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];
처음으로 사용자가 탭하면 모든 것이 정상적으로 작동합니다. 두 번째로 애니메이션 글 머리 기호가 만들어 지지만 기존의 글 머리 기호 애니메이션은 중단됩니다.