← Yop2D

How to move the hero with on-screen arrows?

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

Three on-screen buttons instead of the joystick: ◀ to go left, ▶ to go right, ▲ to jump. Everything is set in the hero's behaviour.

You need:

Step 1: the ground

  1. Put an object in the scene (an image or a Square) and name it sol.
  2. Stretch it so it covers the whole width of the screen.
  3. Select sol, tap ⚙ Object behavior in the Inspector and choose Ground / wall.

Step 2: the hero

  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 Platform character.

Step 3: the three buttons

  1. Tap Object → Interactive → Button with text.
  2. Name it gauche and type ◀ in its Text line.
  3. Tap Object → Interactive → Button with text.
  4. Name it droite and type ▶ in its Text line.
  5. Tap Object → Interactive → Button with text.
  6. Name it saut and type ▲ in its Text line.

Step 4: the setting

  1. Select heros and open ⚙ Object behavior again.
  2. Controls line: Buttons. Then Left button: gauche, Right button: droite, Jump button: saut.

The nodes

No node needed: the behaviour does everything.

Try it

Tap Play: keep your finger on ◀ or ▶ to walk, tap ▲ to jump.

👉 Put the buttons in a HUD (a scene laid over the game) if your camera follows the hero: they will always stay in place (see the A pause menu recipe).