如何在iPhone上创建粒子系统并保留创建的粒子?

发布于 2024-09-03 12:15:21 字数 288 浏览 3 评论 0原文

我需要创建一个粒子系统并保留创建的粒子。我需要用 iPhone 加速计摇动/移动创建的粒子。另外,粒子的数量需要非常高(我需要显示沙子!)。

我没有任何 OpenGLES 编程经验。

经过初步搜索,我发现Cocos2D可以用于粒子生成。但CCParticle系统中没有办法保留粒子。作为解决方法,我尝试在粒子生成结束时创建许多精灵并将它们显示为粒子。但是使用加速计移动少量精灵会大大降低帧速率。

请建议如何实现这一点,以及我是否应该寻找其他框架或者是否有某种类似的演示代码可用。

谢谢, 斯瓦普尼尔

I need to create a particle system and retain the created particles. I need to shake / move the created particles with the iphone accelerometer. Also, the number of particles needs to be very high (I need to show sand!).

I do not have any OpenGLES programming experience.

After initial search, I found Cocos2D can be used for particle generation. But there is no way of retaining the particles in the CCParticle system. As a work around, I tried creating many sprites at the end of particle generation and shown them as particles. But moving few number of sprites with accelerometer drops the frame rate considerably.

Please suggest how this can be achieved and whether I should look for some other framework or if some kind of similar demo code is available.

Thanks,
Swapnil

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

因为看清所以看轻 2024-09-10 12:15:21

给你,iphonearticles,一个适用于 iPhone 的 OpenGL ES 开源粒子生成器。如果您想了解它是如何制作的,请查看源代码。

另外,您可能想查看 本文。它使用 71 Squared 创建的粒子发射器类。

Here you go, iphoneparticles, an open source particle generator in OpenGL ES for iPhone. Check out the source code if you want to get an idea about how it was made.

Also, you may want to take a look at the source code of the demo app presented in this article. It uses a Particle Emitter class created by 71 Squared.

凉城已无爱 2024-09-10 12:15:21

看一下 CAReplicatorLayer,让您可以使用核心动画创建漂亮的粒子系统。 Apple 有一个针对 Mac 的很好的示例,我移植到了 iPad

Take a look at CAReplicatorLayer, which lets you use Core Animation to create nice particle systems. Apple has a good example of this for the Mac, which I ported to the iPad.

风筝在阴天搁浅。 2024-09-10 12:15:21

尝试了所有提到的方法,但没有一个适合我想要实现的目标。

只要我创造粒子,事情就可以了。但是当我开始使用它们作为精灵(或在粒子消失时创建新的精灵)并用加速度计移动它们时,性能真的很糟糕,因为沙粒的数量很大。

所以这里有一个我要尝试的解决方法:

创建一个巨大的精灵表,每个精灵大小为 320 * 480,显示散布在不同位置/方向的沙子,并根据加速度计输入更改精灵。

我知道这听起来像是一个蹩脚的工作,但我创建了一个小的精灵表 POC,而且还不错。

如果您认为此解决方法存在某种缺陷,或者我应该使用其他方法,请告诉我。

谢谢,
斯瓦普尼尔

Tried all the mentioned approaches but none suits what i'm trying to achieve.

Things are ok as long as i create particles. But the moment i start using them as sprites (or create new sprite as particles disappear) and move them with accelerometer the performance is really really bad as the number of sand particles is huge.

So here is a work around i am going to try:

Create a huge sprite sheet with each sprite of size 320 * 480, showing sand scattered in different positions/directions, and change the sprites according to accelerometer inputs.

I know this sound like a lame work around but i created a small sprite sheet POC and it is not so bad.

Please let me know if you think this workaround is somehow flawed or i should be using some other approach.

Thanks,
Swapnil

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文