所以我每秒都在创建一个精灵,但现在我想用 spriteSheetAnimation 替换这个精灵。但是当我运行此代码时,我的应用程序崩溃了:
- (void)spawnCat {
CCSpriteBatchNode *spriteSheet2 = [CCSpriteBatchNode batchNodeWithFile:@"AnimBulle.png"];
[self addChild:spriteSheet2];
// Load up the frames of our animation
NSMutableArray *walkAnimFrames = [NSMutableArray array];
for(int i = 1; i <= 8; ++i) {
[walkAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"AnimBulle%d.png", i]]];
}
CCAnimation *walkAnim = [CCAnimation animationWithFrames:walkAnimFrames
delay:0.1f];
[target runAction:_walkAction];
target.tag = 1;
[_targets addObject:target];
[self addBoxBodyForSprite:target];
[spriteSheet2 addChild:target z:0 tag:1];
id actionMove = [CCMoveTo actionWithDuration:actualDuration
position:ccp(240, 160)];
id actionMoveDone = [CCCallFuncN actionWithTarget:self
selector:@selector(spriteDone:)];
[target runAction:[CCSequence actions:actionMove, actionMoveDone, nil]];
}