Libgdx is a cross platform game development framework for Windows, Linux and Android. I have been using Libgdx from last some months and found it a good game development framework. Currently, I am working on my new project where I have created “Particle Effect”, found it really magical. “Particle editor(particle-editor.jnlp)” is the software that allowed for particle effects to be easily designed. I’ve ported it to libgdx, and you can check it out via JWS by clicking this url:
http://libgdx.googlecode.com/svn/jws/particle-editor.jnlp
Particle effect basically consists of some images that move around. It creates some pretty stunning results with the few images. They are usually good for fire, explosions, smoke, etc. As you can manipulate life, velocity, rotation, scale, etc and observe in real time.
If you can create effect so easily then why to do difficult programming to create such effects???
Follow some simple steps and create magical effect:
1. The first step to create an effect is to choose an image. The example image is just a simple round gradient. Try with different images to create a wide variety of effects. Different shaped images will often combine for some surprising and sometimes very cool looking results.
Remember, when you configure properties, you actually configure the particle emitter that will create and manage the particles.
Let’s talk in terms of some technical terms:
In code, the emitter is the ParticleEmitter class. A particle effect is made up of one or more emitters, which is managed in the lower right of the particle editor. In code, the effect is represented by the ParticleEffect class, which has a list of Particle Emitters.
Some of the amazing effects which you can create from Particle-editor:
Delay: This emitter will do nothing for many milliseconds, after effect starts. You can use it to synchronize multiple emitters.
Note: Delay property has an “Active” button. You can turn off some properties, this will minimize some of the work at runtime.
Duration: How long the emitter will emit particles. But don’t get confused with, how long particles will live, both are different parameters.
Count: It controls the minimum number of particles that must always exist, and the maximum number of particles that can possibly exist. The minimum is nice for making sure particles are always visible, and the maximum lets the emitter know how much memory to allocate.
Emission: This shows how many particles will be emitted per second.
We can watch the video related to, how to apply the Particle Effect on images or object from the bellow link :
http://code.google.com/p/libgdx/wiki/ParticleEditor
After applying the required effect on the image when we will click the save button then we get the output file kaush(any name we
can use) .
kaush file contain the following text :
Untitled
– Delay –
active: false
– Duration –
lowMin: 3000.0
lowMax: 3000.0
– Count –
min: 5
max: 200
– Emission –
lowMin: 0.0
lowMax: 0.0
highMin: 250.0
highMax: 250.0
relative: false
scalingCount: 1
scaling0: 0.627451
timelineCount: 1
timeline0: 0.0
– Life –
lowMin: 15.0
lowMax: 15.0
highMin: 500.0
highMax: 1000.0
relative: false
scalingCount: 3
scaling0: 1.0
scaling1: 0.39215687
scaling2: 0.3
timelineCount: 3
timeline0: 0.0
timeline1: 0.53424656
timeline2: 1.0
– Life Offset –
active: false
– X Offset –
active: false
– Y Offset –
active: false
– Spawn Shape –
shape: point
– Spawn Width –
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
– Spawn Height –
lowMin: 0.0
lowMax: 0.0
highMin: 0.0
highMax: 0.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
– Scale –
lowMin: 0.0
lowMax: 0.0
highMin: 32.0
highMax: 32.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
– Velocity –
active: true
lowMin: 36.0
lowMax: 36.0
highMin: 30.0
highMax: 300.0
relative: false
scalingCount: 1
scaling0: 1.0
timelineCount: 1
timeline0: 0.0
– Angle –
active: true
lowMin: 90.0
lowMax: 90.0
highMin: 45.0
highMax: 135.0
relative: false
scalingCount: 3
scaling0: 1.0
scaling1: 0.0
scaling2: 0.0
timelineCount: 3
timeline0: 0.0
timeline1: 0.5
timeline2: 1.0
– Rotation –
active: false
– Wind –
active: false
– Gravity –
active: false
– Tint –
colorsCount: 3
colors0: 0.023529412
colors1: 0.05882353
colors2: 0.17254902
timelineCount: 1
timeline0: 0.0
– Transparency –
lowMin: 0.0
lowMax: 0.0
highMin: 1.0
highMax: 1.0
relative: false
scalingCount: 4
scaling0: 0.0
scaling1: 1.0
scaling2: 0.75
scaling3: 0.0
timelineCount: 4
timeline0: 0.0
timeline1: 0.2
timeline2: 0.8
timeline3: 1.0
– Options –
attached: false
continuous: false
aligned: false
additive: true
behind: false
– Image Path –
E:android_workspaceWaterBucketAppdatayellow-drop.png
We can directly use the output File of editor in our gaming world as :
To show these in our game first set up a ParticleEffect and an array of emitters:
ParticleEffect effect;
Array<ParticleEmitter> emitters;
SpriteBatch batch;
In the create method we can load the effect file:
effect = new ParticleEffect();
effect.load(Gdx.files.internal(“data/kaush”),Gdx.files.internal(“data”));
In the render method we can draw the effect:
//world.waterDropX and world.waterDropY are the co-ordinate of image.
effect.setPosition( world.waterDropX, world.waterDropY);
emitters = newArray(effect.getEmitters());
effect.getEmitters().add(emitters.get(0));
emitters.get(0).start();
effect.draw(batch, Gdx.graphics.getDeltaTime());
Finally, you will get the magical Particle effect like:
Hope, you will enjoy it!!
– By
Arvind Kaushal
Comments are closed.