FXGL
FXGL copied to clipboard
BUG: In the update method of the ParticleSystem, the particle objects are not correctly recycled back to the object pool. Here, the incorrect reference p of Point2D is used for the recycling process.
com.almasb.fxgl.particle.ParticleSystem
override fun onUpdate(tpf: Double) {
emitters.forEach { (emitter, p) ->
val particlesList = particles[emitter]!!
particlesList.addAll(emitter.emit(p.x, p.y))
val iter = particlesList.iterator()
while (iter.hasNext()) {
val particle = iter.next()
if (particle.update(tpf)) {
iter.remove()
pane.children.remove(particle.view)
Pools.free(p) //# Here, the incorrect objects have been retrieved.
} else {
if (particle.view.parent == null)
pane.children.add(particle.view)
}
}
}
}
Perhaps this class is not used frequently. From what I can see, it is correct in the ParticleComponent.
Well spotted! It should be particle, not p