A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/AlmasB/FXGL/issues/1318 below:

Particules Emitters are Spawning particules at zIndex = 0 · Issue #1318 · AlmasB/FXGL · GitHub

Describe the bug
I've noticed that all particules were draw under anything that had a zIndex set.

To Reproduce

  1. Create a Rectangle with zIndex = 1000 that fills the screen
  2. Create a Particules Emitter (I tried Rain & Smoke, same behavior)
  3. Start the emitter
  4. You won't see any particules

Expected behavior
Particules need to be displayed at a desired zIndex.

Additional context / possible fixes
The Bug is caused by this strategy:

open class ParticleComponent(val emitter: ParticleEmitter) : Component() {
    ...
    /**
     * This is the entity whose view is used to render particles.
     * Use of extra entity allows to render particles independently from
     * the entity to which this component is attached. Otherwise, the entire
     * set of emitted particles will be moved based on entity's view.
     */
    val parent = Entity()
    ...

In fact, the ParticuleComponent will create it's own "ghost" entity instead of using the Entity tied to the Component. This ensures that particules stay were they were emitted from (which is a desired behavior, of course). The Particule has an ImageView that will ensure that the particule is spawned at the X & Y desired positions. But, the problem is related to how the zIndex sorting works. An ImageView doesn't have a zIndex strategy, it's handled by the FXGL Scene (re-adding Nodes to the Scene after a zIndex sort).

Solution
Simply assign the zIndex of the real ParticuleComponent entity to the "Ghost" entity by default. Important: The "Ghost" entity zIndex will not be bind to the real ParticuleComponent entity, to prevent Particule relocations.

@AlmasB I'll create a PR soon.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4