← Yop2D

How to show a score?

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

A score that goes up and shows on screen. To try it, a +1 button gives points; then you replace it with a coin to collect.

You need:

Step 1: the score variable

  1. In the left panel, Scene tab, GAME VARIABLES section: tap New variable.
  2. Name (no spaces): score; Type: Whole number; Starting value: 0. Then Apply.

Step 2: the score text

  1. Tap Object → Texts → Text, place it at the top of the screen.
  2. Name it score_label and type 0 in its Text line.

Step 3: a button to earn points

  1. Tap Object → Interactive → Button with text.
  2. Name it plus and type +1 in its Text line.

Step 4: the nodes

  1. Open the Blueprint.
  2. On Object Click: Object plus.
  3. Add to Variable: variable score, Value to add 1.
  4. Modify Text: Object score_label, New text =score.
  5. Connect the three nodes in this order.

The nodes

On Object Clickplus
→
Add to Variablescore · + 1
→
Modify Textscore_label · =score

Try it

Tap Play, then the +1 button several times: the score shows 1, 2, 3…

👉 =score means: the value of the score variable. You can write =score * 10 to count 10 points per coin.
👉 For a real coin to collect: replace On Object Click with If object touches Tag (see the Coins and score guide).