Particle System libGDX [closed]

久未见 提交于 2019-12-02 19:26:31

Define a particle effect in your game class:

public ParticleEffect particleEffect;

Initialize it:

    particleEffect = new ParticleEffect();
    particleEffect.load(Gdx.files.internal("data/particleEffect.p"), 
            Gdx.files.internal("data"));

In your render() method, position it at the place you want particles to be emitted (explosion location):

    particleEffect.setPosition(world.effectX, world.effectY);

And draw it finally (also within render()):

    particleEffect.draw(spriteBatch, delta);

That's it, pretty simple and straightforward.

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.

Sort of docs in this blog post: http://www.badlogicgames.com/wordpress/?p=1255 Blog post was copy pasted to the wiki: https://code.google.com/p/libgdx/wiki/ParticleEditor When real docs are written in the future, they will be there.

Also, run it from source for the latest, as the JWS is a pain to update.

Now a video: http://www.badlogicgames.com/wordpress/?p=2462

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!