我想在游戏中的松鼠英雄触摸水果时为其设置动画。动画后必须将水果从场景中移除。我已经尝试了 2 周,但没有做对。我的 spritesheet 有 6 帧精灵动画。
目前,当英雄与水果相交时,我正在执行以下代码:
NSMutableArray *burst = [NSMutableArray array];
for(int i = 1; i <= 6; ++i) {
[burst addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"Fruit01000%d.png", i]]];
}
CCAnimation *walkAnim = [CCAnimation animationWithFrames:burst delay:0.02f];
CCActionInterval *animAction = [CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO];
[expl stopAllActions];
expl.visible = TRUE;
expl.position = ccp(coinColl.position.x,coinColl.position.y);
cleanupAction = [CCCallFuncND actionWithTarget:self selector:@selector(explOver:) data:expl];
seqF = [CCSequence actions:animAction, cleanupAction, nil];
[expl runAction:seqF];
[platformLayer removeChild:coinColl cleanup:YES];
[self sumScore];
[coinLabel setString: [NSString stringWithFormat:@"%i",appDelegate.coinScore+appDelegate.levelScore]];
explOver() 函数:
-(void) explOver:(CCSprite*)explosion{
explosion.visible = FALSE;
}
它部分工作,一些水果不显示动画,并且跳转到下一个场景时应用程序崩溃,给出错误“指针被释放未分配”