ℹ️ For Yop2D Next, the new 2D + 3D version of Yop2D (coming soon). Button and node names are those of Yop2D Next.
🔍 How do I…? All short recipes, with a search
A switch the player taps to turn the music on or off. Its value goes into a variable, and a node chooses what happens next.
You need:
- a 2D project open in Yop2D Next.
Step 1: the switch
- Tap Object → Interface elements → Switch.
- Name it musique.
- In the Inspector, tap the Settings and style… button, Variable that receives the value (optional) line → New variable…: type son, then close the window.
Step 2: the nodes
- Open the Blueprint.
- When an interface element changes: Object musique
- If a variable…: Variable son, Comparison is at least, Value 1
- True output → Play music (Music file : Import or listen to sounds…)
- False output → Stop music
The nodes
When an interface element changesmusique
→
If a variable…son · is at least 1
True →
Play music
If a variable…
False →
Stop music
Try it
Tap Play, then the switch: the music starts. Tap it again: it stops.
👉 The switch value can also be read with
=musique.progression: 1 for ON, 0 for OFF (see the A slider and its value recipe).