Hello, i have a problem. The function execute, only execute effect twice and also wrong sizes. One huge explosion and on very small which seems correct that is the scaled one. Then it does not show anymore any effects. I would like to execute effects by name and positon. Since i will have a list with effects.
public class Effect {
private HashMap<String, ParticleEffect> effectList;
private ParticleEffect effect;
private ParticleEffectPool effectPool;
private Array<ParticleEffectPool.PooledEffect> effects;
public Effect() {
effectList = new HashMap<String, ParticleEffect>();
effects = new Array<ParticleEffectPool.PooledEffect>();
}
public void execute(String name, Vector2 position) {
// Create effect:
effect = effectList.get(name);
effect.scaleEffect(0.12f);
effectPool = new ParticleEffectPool(effect, 1, 2);
ParticleEffectPool.PooledEffect poolObtain = effectPool.obtain();
poolObtain.setPosition(position.x, position.y);
effects.add(poolObtain);
poolObtain.start();
}
public void addEffect(String name, ParticleEffect eff) {
effectList.put(name, eff);
}
public void render(SpriteBatch batch, float deltaTime) {
// Update and draw effects:
for (int i = effects.size - 1; i >= 0; i--) {
ParticleEffectPool.PooledEffect effect = effects.get(i);
effect.draw(batch, deltaTime);
if (effect.isComplete()) {
effect.free();
effects.removeIndex(i);
}
}
}
}