ios - 添加到移动 Sprite 时,CCParticleSystemQuad 未被释放

标签 ios objective-c cocos2d-iphone ccparticlesystem

我正在尝试在 cocos2d 中添加粒子尾迹效果,我设法通过将 CCParticleSystemQuad 发射器作为子级添加到移动 Sprite 来实现。 但我观察到这个发射器最终没有被释放。

如果我将这个发射器添加到同一个 sprite,但保持它静止并且根本不移动,发射器会被释放。

我不知道为什么会这样..

代码有点像这样..

CCParticleSystemQuad *emitter = [[[CCParticleSystemQuad alloc] initWithFile:@"myEffect.plist"] autorelease];
emitter.positionType = kCCPositionTypeFree;
emitter.autoRemoveOnFinish = YES;
[movingSprite addChild:emitter z:movingSprite.zOrder + 1000];

最佳答案

确保你调用了[emitter removeFromParentAndCleanup:YES];

这是我的一个 similar question

找出保留对象的位置,按照 Morion 在上述线程中的回答。

快速解决方案:

CCParticleSystemQuad *emitter = [CCParticleSystemQuad particleWithFile:@"myEffect.plist"];
emitter.positionType = kCCPositionTypeFree;
emitter.autoRemoveOnFinish = YES;
[movingSprite addChild:emitter z:movingSprite.zOrder + 1000];

//To remove
[emitter stopSystem];
[emitter removeFromParentAndCleanup:YES];

关于ios - 添加到移动 Sprite 时,CCParticleSystemQuad 未被释放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16116594/

相关文章:

ios - 健康栏的 CCProgressNode 不工作

ios - 有没有办法改变 iOS 大标题的左边距?

objective-c - 如何创建可变函数? (可以接受任意数量的参数)

ios - 在 UIPageViewController 上方画一条路径

ios - 在主表/明细表上使用不同的 xib 文件查看所选的项目 iOS

ios - 苹果通知可靠性

iphone - 如何在cocos2d场景中集成UIViewcontroller

ios - 在cocos2d中实现生命/积分系统

ios - 如何退出具有权利的应用程序?

iOS - tableview 上的 PopUpViewController 出现在顶部