← Yop2D

How to make a “Game over” screen?

Beginner guide · no code

Français · English · Español · Deutsch · Italiano · Português · Русский · 中文 · 日本語 · العربية

ℹ️ 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:

Step 1: the hero and the enemy

  1. Put an object in the scene (an image or a Square) and name it heros.
  2. Select heros, tap ⚙ Object behavior in the Inspector and choose Top-down character.
  3. Tap Object → Interactive → Joystick.
  4. Put an object in the scene (an image or a Square) and name it ennemi.
  5. In the Inspector, Tag (family of objects) line, type ennemi.

Step 2: the GameOver scene

  1. Left panel, Scene tab, SCENES section: tap New scene, choose 2D scene and call it GameOver.
  2. Tap Object → Texts → Text.
  3. Name it perdu_label and type Game over! in its Text line.
  4. Tap Object → Interactive → Button with text.
  5. Name it rejouer and type Play again in its Text line.

Step 3: the GameOver scene's nodes

  1. Open the Blueprint.
  2. On Object Click: Object rejouer → Go to scene: Scene Game

Step 4: the game's nodes

  1. Tap the Game scene in the list to open it.
  2. Open the Blueprint.
  3. 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.