0

我有一个CCSprite可以在 iPhone 屏幕上弹跳的。这个精灵有一个CCParticleSystemQuad作为子节点。粒子只是小而简单的圆圈,在移动的精灵后面跟随。一切正常,直到精灵由于与屏幕边缘碰撞而旋转。当这种情况发生时,现有的粒子会突然被绘制在一个奇怪的位置。

知道为什么会这样吗?

到目前为止,我已经尝试了几件事。首先,我尝试positionType了粒子系统的所有三个值。这些都没有解决旋转问题。实际的旋转是用 a 完成的CCRotateTo。删除此操作可修复粒子位置问题。所以也许在 a 上旋转一个CCSprite子节点CCLayer可以代替我当前的CCSprite. 我尝试通过http://www.cocos2d-iphone.org/forum/topic/63951阅读,但这有点超出我的想象。非常感谢任何反馈和建议!

编辑#1我找到了一个快速解决方法:在CCRotateTo我告诉尾随粒子到resetSystem. 但是我仍然想了解奇怪的绘图行为的原因。

4

1 回答 1

1

I think this is happening because of the CCParticleSystem being a child of the CCSprite, then any position or rotation that you do on the sprite will affect the behavior of all the particles that are being and have already been emitted. So if you have some trailing particles that are still lingering on screen, they are still children of the CCSprite, and rotating it will cause all of the lingering particles to rotate around the sprite's current position.

If you want to eliminate this effect, you could add the CCParticleSystem to the layer, so that it will be unaffected by the CCSprite's rotation. The downside to this approach is that you will have to add code to have the CCParticleSystem track the position of the CCSprite since it is no longer a child of the CCSprite. That should be pretty easy to do however.

于 2012-12-22T10:15:02.857 回答