Skip to content

2d particle effects

Robin S edited this page Oct 26, 2013 · 4 revisions

See this article on how to use the ParticleEditor.

Documentation is currently lacking for libgdx particles, sorry.

There is a video tutorial though:

Libgdx 2D Particle Effects

Pooled effect example:

ParticleEffectPool bombEffectPool;
Array<PooledEffect> effects = new Array();
...
ParticleEffect bombEffect = new ParticleEffect();
bombEffect.load(Gdx.files.internal("particles/bomb.p"), atlas);
bombEffectPool = new ParticleEffectPool(bombEffect, 1, 2);
...
// Create effect:
PooledEffect effect = bombEffectPool.obtain();
effect.setPosition(x, y);
effects.add(effect);
...
// Update and draw effects:
for (int i = effects.size - 1; i >= 0; i--) {
	PooledEffect effect = effects.get(i);
	effect.draw(batch, delta);
	if (effect.isComplete()) {
		effect.free();
		effects.removeIndex(i);
	}
}
...
// Reset all effects:
for (int i = effects.size - 1; i >= 0; i--)
    effects.get(i).free();
effects.clear();

Table of Contents

a note from the translation

Wiki Style Guide

Clone this wiki locally