You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: particles/particlefx_set_get/example.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ This example focuses on this feature. It toggles a ParticleFX between two setups
32
32
-`default_material`
33
33
-`glow_material`
34
34
35
-
This makes it easy to switch the emitter `image` and `material` directly from code.
35
+
The current script switches the emitter `image`directly from code and keeps `default_material` active for the shown setup.
36
36
37
37
4. The example uses 2 atlases with given animations:
38
38
@@ -45,20 +45,22 @@ The atlases are set up to contain the animation ids used by the script, so the e
45
45
46
46
The script keeps two hardcoded setups and toggles between them whenever you click or tap:
47
47
48
-
1.`particles.atlas` + glow material
48
+
1.`particles.atlas` + default particle material
49
49
`emitter_top` uses `coin`
50
50
`emitter_bottom` uses `smoke`
51
51
2.`sprites.atlas` + default particle material
52
52
`emitter_top` uses `ship_red`
53
53
`emitter_bottom` uses `ship_dark`
54
54
55
-
When the setup changes, the script:
55
+
On startup the script stores the current atlas name, reads back the authored emitter properties, writes them into the labels, and starts the ParticleFX. When the setup changes after that, the script:
56
56
57
-
1. stops the ParticleFX
58
-
2. calls `set_emitter_properties()` for each emitter to set `image`, `animation`, and `material`
59
-
3. calls `get_emitter_properties()` to read the current values back with `go.get()`
60
-
4. writes the values into the two labels
61
-
5. plays the ParticleFX again
57
+
1. stops the ParticleFX with `{ clear = true }`
58
+
2. flips `self.atlas_name` between `sprites_atlas` and `particles_atlas`
59
+
3. looks up the atlas resource and the correct animation pair from the `ANIMATIONS` table
60
+
4. calls `set_emitter_properties()` for each emitter to set `image`, `animation`, and `material`
61
+
5. calls `get_and_print_emitter_properties()` to read the current values back with `go.get()`
62
+
6. writes them into the two labels
63
+
7. plays the ParticleFX again
62
64
63
65
The helper function `set_emitter_properties()` applies properties per emitter by passing the emitter id in `keys`:
The helper function `get_emitter_properties()` uses the same `keys` pattern with `go.get()` and writes the result into the labels, so the example shows which values are currently active for each emitter.
73
+
The helper function `get_and_print_emitter_properties()` uses the same `keys` pattern with `go.get()` and writes the result into the labels, so the example shows which values are currently active for each emitter.
72
74
73
-
One important limitation: **emitter property changes only affect the next play**. That is why the script stops and plays the ParticleFX around each property update.
75
+
One important limitation: **emitter property changes only affect the next play**. The script therefore stops the ParticleFX, clears any already spawned particles, applies the new emitter overrides, and then plays it again.
0 commit comments