# Unable to draw single particle effect at two places

I am using Libgdx ParticleEffect to draw a fire particle effect .

The issue I have is that when I try to render a ParticleEffect at two different locations within single game loop, only the last draw call has the effect drawn on screen. I update the Particle effect only once per game loop but set its position to two distinct locations and draw it. Is this a trivial problem with Libgdx ParticleEffect:

ParticleEffect effect = new PartcleEffect();
effect.start();


In render :

effect.update(deltaTime);

effect.setPosition(x1,y1);
effect.draw(batch);

effect.setPosition(x2,y2);
effect.draw(batch);


Can someone tell me why it isn't working?

When you call effect.setPosition(...), it changes the position of all the emitters, but not of the particles. In libGDX, there is currently no way of changing the position of a single particle, so in order to draw particles at 2 locations, you must do the following:

// Pseudo-code
move effect at position 1
move effect at position 2
update effect
draw effect


You must create particles at the 2 different locations to achieve the effect you want.

you have to create an array of pooled effects

Array<PooledEffect> effects = new Array<PooledEffect>();


so, in render(), you draw all effects from array.

for(int i = 0; i < blocos.size();i++){
if(obj.colision(block.get(i),config)) {

PooledEffect effect = block.get(i).getEffectPool().obtain();
effect.setPosition(block.get(i).getX(), block.get(i).getY());