谁能给我一个很好的例子,说明从哪里开始在 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何创建漩涡/漩涡效果?How to create whirlpool/vortex effect?(如何创建漩涡/漩涡效果?)
Android/Java - GoogleMaps FragmentActivity 上的自定义视图Android/Java - Custom View on GoogleMaps FragmentActivity isnt shown(Android/Java - GoogleMaps FragmentActivity 上的自定义视图未显示)
LibGdx 2 半屏“按钮"LibGdx 2 half screen quot;buttonsquot;(LibGdx 2 半屏“按钮)
libgdx 剪切图像libgdx Cutting an image(libgdx 剪切图像)
如何在启动 Android LibGDX 项目时修复 NoClassDefFounHow do I fix a NoClassDefFoundError while launching Android LibGDX Project?(如何在启动 Android LibGDX 项目时修复 NoClassDefFoundError?)
如何让玩家通过相机被摧毁?How to make player get destroyed through camera?(如何让玩家通过相机被摧毁?)