Skip to content

Commit

Permalink
Properly reset particles in the pool
Browse files Browse the repository at this point in the history
  • Loading branch information
fgnm committed Feb 24, 2024
1 parent 0bfc5d1 commit 3677ced
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public interface IEmitter {
void pause();
void resume();
void restart();
void reset();
float getDelayRemaining();
void update(float delta);
ParticleEmitterDescriptor getEmitterGraph();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,13 @@ public void restart () {
totalTime = 0;
}


public void reset () {
for (int i = 0; i < emitters.size; i++) {
emitters.get(i).reset();
}
paused = false;
totalTime = 0;
}

public Array<IEmitter> getEmitters () {
return emitters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ParticleEffectDescriptor getParticleEffectDescriptor() {
public void free(PooledParticleEffectInstance object) {
super.free(object);

object.restart();
object.reset();
}

public class PooledParticleEffectInstance extends ParticleEffectInstance {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,9 @@ public void setTint(float r, float g, float b, float a) {
public void setTint(Color color) {
tint.set(color);
}

public void reset() {
initialized = false;
activeParticles.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ public void restart () {
isStopped = false;
}

@Override
public void reset() {

}

@Override
public boolean isStopped() {
return isStopped;
Expand Down

0 comments on commit 3677ced

Please sign in to comment.