Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Particle System libGDX [closed]

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!

like image 259
Alex_Hyzer_Kenoyer Avatar asked Mar 05 '12 16:03

Alex_Hyzer_Kenoyer


2 Answers

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.

like image 168
Dominik Bucher Avatar answered Sep 22 '22 20:09

Dominik Bucher


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

like image 39
NateS Avatar answered Sep 23 '22 20:09

NateS