我正在用cocos2d进行游戏,并且我想要删除一组精灵。例如,我可能在屏幕上有一堆字符,但当我的游戏结束时,我想清理它们。现在我已经创建了一个特殊效果(粒子系统)作为分心,但是因为它是透明的并且不能覆盖所有可以看穿的屏幕,并且在我将它们从图层中移除时观察精灵消失。在游戏循环中失速并自然移除精灵
此外,由于指令对用户的执行速度如此之快,它看起来好像在粒子效应开始之前精灵会消失!
对我的2个问题有什么建议吗?谢谢。
NSMutableArray *toRemove = [[NSMutableArray alloc] init]; // array of sprites that I collect to remove
spriteCount = 0;
if([self findAllSprites:parent forRemoval:toRemove] > 0){ // is there is at least one sprite to delete. If not then don't do anything
[self specialEffect]; // runs for maybe 3 seconds.
// how can I stall here so that the sprites aren't removed "instantaneously"?
for (Character* aCharacter in toRemove) {
[aCharacter.parent remove:aCharacter];
}
}
谢谢!这非常有效。 – Stu 2009-06-19 16:42:46