Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Particules Emitters are Spawning particules at zIndex = 0 #1318

Closed
DeathPhoenix22 opened this issue Nov 6, 2023 · 0 comments
Closed

Particules Emitters are Spawning particules at zIndex = 0 #1318

DeathPhoenix22 opened this issue Nov 6, 2023 · 0 comments

Comments

@DeathPhoenix22
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant