CCParticleSystem删除最佳做法

问题描述 投票:2回答:1

我的问题是针对用cocos2d v1.1.0-beta2b针对ios编写的应用程序:

什么消除/释放 CCParticleSystem最佳实践

我知道的一种方法是使用setAutoRemoveOnFinish:YES。

[emitter setAutoRemoveOnFinish:YES];
[emitter stopSystem];

另一种方法是使用removeChild手动删除发射器。

还有其他吗? 通常推荐哪种方式?

附带说明一下,是否存在有关cocos2d v1.1.0-beta2b下CCParticleSystem删除/发布的已知问题?

ios cocos2d-iphone ccparticlesystem
1个回答
1
投票

要删除粒子系统,只需将其从其父节点中删除。 这是最好的方法。

如果您的粒子系统没有无限的持续时间,则最好的方法是使用setAutoRemoveOnFinish 。 粒子系统结束时,它将自动从父节点中删除系统。

如果您的粒子系统具有无限的持续时间,则将removeChildcleanUp:YES一起cleanUp:YES (您无需在stopSystem before设置stopSystem before )。 这样,系统将被强制删除。

或者,您可以将stopSystemsetAutoRemoveOnFinish:YES ,并且系统将在最后一个粒子结束后删除该系统。 这样,系统可以顺利卸下。

其他提示:

  • 使用CCParticleSystemQuad而不是CCParticleSystem
  • 建议您使用autorelease构造函数创建粒子系统,例如[CCParticleSystemQuad particleWithFile:][CCParticleSystemQuad particleWithTotalParticles:]
  • 当然,如果您有保留它的属性,请使用release
© www.soinside.com 2019 - 2024. All rights reserved.