09 Particle Effect
In this chapter, we will spawn a hit particle when a note reaches the judgment line.
Shared Particle
The play section already declared Particles.note. Watch mode reuses that particle effect.
Playing
In play mode, a tap triggers the particle effect. During normal watch playback, a note leaves its active range when it reaches the judgment line. Sonolus then calls terminate, so watch mode can spawn the particle from that callback.
Edit guide/watch/note.py. Add is_skip to the existing runtime import and add the shared particle import:
python
from sonolus.script.runtime import is_skip, scaled_time
from guide.lib.particle import ParticlesThen add terminate after update_parallel:
python
class WatchNote(WatchArchetype):
# ...
def terminate(self):
if is_skip():
return
particle_layout = Rect.from_center(
Vec2(0, 1),
Vec2(4 * Config.note_radius, -4 * Config.note_radius),
)
Particles.note.spawn(particle_layout, duration=0.3)Seeking can also make a note leave its active range. is_skip() returns True while Sonolus processes that transition, so the guard prevents a spurious hit effect. At this checkpoint, replay misses still produce particles. Chapter 10 will suppress them after the recorded judgment is available.
Let a note reach the line without seeking: it should produce a particle. Then seek across a note in either direction: the skipped note should not produce a particle.