gpt4 book ai didi

c++ - 改变setPosition时cocos2d-x中的粒子闪烁

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:31:55 25 4
gpt4 key购买 nike

我正在使用一个粒子,稍微修改了 CCParticleFlower 和 positionVar 以垂直线的形式,从上到下。在 CCNode 更新中,我在整个屏幕上不断地从左到右改变粒子的位置,当它到达右侧时,我将 x 设置为 0 并开始向右滚动。

问题是当我将 X 值重置为 0 时,所有粒子都会闪烁,它们会消失大约一帧并出现在下一帧,这会导致令人讨厌的闪烁效果。

在 win32、android 和 ios 上,当我将 X 值增加一个小数字时不会发生这种情况,但是当粒子位置重置为其起始位置时它会闪烁。我使用的是最新的 1.1 版本(master 分支)

最佳答案

我最近遇到了一些类似的问题,每当它们的 parent 改变方向时,粒子就会跳来跳去。我不确定这是否是完全相同的问题,但这是我发现对我的问题有帮助的线程:

http://www.cocos2d-iphone.org/forum/topic/17167

相关帖子:

I just encountered the same problem and it took me a while to get to the bottom of it, >here's the low down: do not use

[self schedule:@selector(NextFrame:)];

Instead, use

[self scheduleUpdate];

and rename NextFrame: to update:

Using a custom selector schedules your update at the very end of the CCScheduler queue, in other words, it will cause your NextFrame: method to be called AFTER the particle system's update: method, because the particle system schedules its own update method with a priority of 1.This is not good because the position of the quads for the particles are updated using the current position of the emitter, and then the emitter is moved in your NextFrame: method, which causes all the particles to be moved again because the position of the emitter is really the position of the CCNode that draws the particles.By using scheduleUpdate, you really schedule your update: method with a priority of 0, which means it will be called before the particle system's update: method and all will be well.

所以基本上,向您的类添加一个更新方法并调用 scheduleUpdate 而不是手动安排它。

关于c++ - 改变setPosition时cocos2d-x中的粒子闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11064242/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com