-
-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: emit particles at initial Entity zIndex instead of zIndex 0, closes
- Loading branch information
1 parent
f4937ff
commit 4c740dd
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
fxgl-entity/src/test/kotlin/com/almasb/fxgl/particle/ParticleComponentTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* FXGL - JavaFX Game Library. The MIT License (MIT). | ||
* Copyright (c) AlmasB ([email protected]). | ||
* See LICENSE for details. | ||
*/ | ||
@file:Suppress("JAVA_MODULE_DOES_NOT_DEPEND_ON_MODULE") | ||
package com.almasb.fxgl.particle | ||
|
||
import com.almasb.fxgl.entity.Entity | ||
import com.almasb.fxgl.entity.GameWorld | ||
import com.almasb.fxgl.entity.component.ComponentHelper | ||
import org.hamcrest.CoreMatchers.`is` | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.junit.jupiter.api.Assertions.assertNotNull | ||
import org.junit.jupiter.api.Assertions.assertNull | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
|
||
/** | ||
* | ||
* @author Jean-Rene Lavoie ([email protected]) | ||
*/ | ||
class ParticleComponentTest { | ||
|
||
private lateinit var world: GameWorld | ||
private lateinit var particle: ParticleComponent | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
world = GameWorld() | ||
particle = ParticleComponent(ParticleEmitter()) | ||
} | ||
|
||
@Test | ||
fun `Create ParticleComponent with zIndex`() { | ||
assertNull(particle.entity) | ||
assertNotNull(particle.parent) | ||
assertThat(particle.parent.zIndex, `is`(0)) | ||
|
||
val e = Entity() | ||
e.zIndex = 100 | ||
|
||
ComponentHelper.setEntity(particle, e) | ||
world.addEntity(e) | ||
particle.onAdded() | ||
particle.onUpdate(1.0) | ||
|
||
assertThat(particle.parent.zIndex, `is`(100)) | ||
|
||
e.zIndex = 200 | ||
particle.onUpdate(1.0) | ||
|
||
assertThat(particle.parent.zIndex, `is`(100)) | ||
} | ||
|
||
} |