ℹ️ 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
When the hero touches an enemy, the game switches to a Game over! screen with a Play again button. That screen is a separate scene.
You need:
- a 2D project open in Yop2D Next.
Step 1: 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 2: the GameOver scene
- Left panel, Scene tab, SCENES section: tap New scene, choose 2D scene and call it GameOver.
- Tap Object → Texts → Text.
- Name it perdu_label and type Game over! in its Text line.
- Tap Object → Interactive → Button with text.
- Name it rejouer and type Play again in its Text line.
Step 3: the GameOver scene's nodes
- Open the Blueprint.
- On Object Click: Object rejouer → Go to scene: Scene Game
Step 4: the game's nodes
- Tap the Game scene in the list to open it.
- Open the Blueprint.
- If object touches Tag: Object heros, Tag (family of objects touched) ennemi → Go to scene: Scene GameOver
The nodes
If object touches Tagheros · ennemi
→
Go to sceneGameOver
On Object Clickrejouer
→
Go to sceneGame
Try it
Tap Play and run into the enemy: the Game over! screen appears. Tap Play again: the game starts over.
👉 A scene always starts over as it was at the start, but the game's variables keep their value: set the score back to 0 with Modify Variable just before Go to scene.