粒子系统 libGDX [英] Particle System libGDX

查看:25
本文介绍了粒子系统 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆