I have a problem with ParticleEffectPool
in libGDX - the first effect does not show, but why does it work after that?
Here's the code for setting it up:
destroyEffect = new ParticleEffect();
destroyEffect.load(Gdx.files.internal("destroy.txt"), Gdx.files.internal(""));
pool = new ParticleEffectPool(destroyEffect, 10, 100);
activeEffects = new Array<ParticleEffectPool.PooledEffect>();
When wanted to show the effect, these call was called:
ParticleEffectPool.PooledEffect effect = pool.obtain();
if (effect != null) {
effect.setPosition(x, y);
activeEffects.add(effect);
}
During render():
for (int i = 0; i < activeEffects.size;) {
ParticleEffectPool.PooledEffect effect = activeEffects.get(i);
if (effect.isComplete()) {
pool.free(effect);
activeEffects.removeIndex(i);
}
else {
effect.draw(batch, deltaTime);
i++;
}
}
This seems pretty straight forward to me, but the first time it does not work.