ℹ️ 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
The hero has 3 lives, shown on screen. When it touches an enemy, it loses a life and blinks. At 0, the scene starts over.
You need:
- a 2D project open in Yop2D Next.
Step 1: the vies variable
- Left panel, Scene tab, GAME VARIABLES section: tap New variable. Name (no spaces): vies; Type: Whole number; Starting value: 3. Then Apply.
Step 2: the lives text
- Tap Object → Texts → Text.
- Name it vies_label and type 3 in its Text line.
Step 3: the hero and the enemy
- Put an object in the scene (an image or a Square) and name it heros.
- Select heros, tap ⚙ Object behavior in the Inspector and choose Top-down character.
- Tap Object → Interactive → Joystick.
- Put an object in the scene (an image or a Square) and name it ennemi.
- In the Inspector, Tag (family of objects) line, type ennemi.
Step 4: the nodes
- Open the Blueprint.
- If object touches Tag: Object heros, Tag (family of objects touched) ennemi
- Add to Variable: Variable vies, Value to add -1
- Modify Text: Object vies_label, New text
=vies - Blink: Object heros, Duration (milliseconds, 0 = endless) 1500
- If a variable…: Variable vies, Comparison is at most, Value 0
- True output → Modify Variable (Variable vies, Value 3) → Restart the scene
The nodes
If object touches Tagheros · ennemi
→
Add to Variablevies · -1
→
Modify Text=vies
→
Blinkheros · 1500
→
If a variable…vies · is at most 0
If a variable…
True →
Modify Variablevies · 3
→
Restart the scene
Try it
Tap Play and touch the enemy: the number goes down and the hero blinks. At 0, everything starts over with 3 lives.
👉 For a real end screen, replace Restart the scene with Go to scene (see the A “Game over” screen recipe).