Particle System libGDX(粒子系统 libGDX)
问题描述
谁能给我一个很好的例子,说明从哪里开始在 libGDX 中制作粒子系统?我已经查看了 libGDX 源代码中的测试示例,但我仍然无法理解它.也许只是对它的一个很好的解释会有所帮助.我在想我想用很多彩色粒子制作某种爆炸.非常感谢任何帮助!
Can anyone give me a good example of where to start with making a particle system in libGDX? I have looked at the test example in the libGDX source but I am still having trouble getting my head around it. Maybe just a good explanation of it will help. I'm thinking I want to make some sort of explosion with a lot of colorful particles. Any help is greatly appreciated!
推荐答案
在你的游戏类中定义一个粒子效果:
Define a particle effect in your game class:
public ParticleEffect particleEffect;
初始化它:
particleEffect = new ParticleEffect();
particleEffect.load(Gdx.files.internal("data/particleEffect.p"),
Gdx.files.internal("data"));
在您的 render()
方法中,将其放置在您希望发射粒子的位置(爆炸位置):
In your render()
method, position it at the place you want particles to be emitted (explosion location):
particleEffect.setPosition(world.effectX, world.effectY);
最后绘制(也在render()
中):
particleEffect.draw(spriteBatch, delta);
就是这样,非常简单明了.
That's it, pretty simple and straightforward.
另一件事,效果本身,看看 Nate 的粒子编辑器,http://libgdx.googlecode.com/svn/jws/particle-editor.jnlp.使用编辑器,您应该能够创建漂亮的效果.否则,从示例中复制粒子文件并进行修改.
Another thing, the effect itself, have a look at the Particle Editor by Nate, http://libgdx.googlecode.com/svn/jws/particle-editor.jnlp. Using the editor you should be able to create nice effects. Otherwise, copy the particle file from the examples and modify it.
这篇关于粒子系统 libGDX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:粒子系统 libGDX


- 如何使 JFrame 背景和 JPanel 透明且仅显示图像 2022-01-01
- 在 Java 中,如何将 String 转换为 char 或将 char 转换 2022-01-01
- 未找到/usr/local/lib 中的库 2022-01-01
- 如何指定 CORS 的响应标头? 2022-01-01
- 转换 ldap 日期 2022-01-01
- java.lang.IllegalStateException:Bean 名称“类别"的 BindingResult 和普通目标对象都不能用作请求属性 2022-01-01
- Eclipse 的最佳 XML 编辑器 2022-01-01
- 获取数字的最后一位 2022-01-01
- 将 Java Swing 桌面应用程序国际化的最佳实践是什么? 2022-01-01
- GC_FOR_ALLOC 是否更“严重"?在调查内存使用情况时? 2022-01-01