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;
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With