Part 3 — Coins, your first logic graph and a HUD

Collectables, a score that goes up, and text on screen. This is where it becomes a game.

14 min read

A level you can walk around is not yet a game. It becomes one the moment there is something to get and a number that goes up.

Make a coin

  1. Press , generator pickup, name coin.
  2. Options: { "palette": "canary", "radius": 10 }.
  3. Add it and place one above a platform.
  4. Rename it Coin.

Tags: the most important idea here

You are about to write one rule that covers every coin in the level, however many you make. That works because rules are written in terms of tags, not individual objects.

  1. With the coin selected, find Tags in the Inspector.
  2. Add the tag coin.
  3. Select the Player and add the tag player.

Coins should not fall

Leave the coin's physics on but set the body to static. It needs a body to be detected, but it should hang in the air rather than dropping to the floor.

Now scatter them

Select the coin and press Ctrl/Cmd + D a dozen times, placing each copy somewhere worth reaching. Duplicates keep the tag and the physics, so every one is picked up by the rule you are about to write.

Your first logic graph

Switch to the Logic tab (or press 2). You get an empty canvas and a palette of nodes on the left.

A graph starts at an event and follows the wires from its output. You are building this:

On Overlap  (player, coin)
  └─ Destroy   (other)
       └─ Add To Variable   score + 10
  1. Drag On Overlap from the palette onto the canvas.
  2. Select it. In the Inspector set Tag A to player and Tag B to coin.
  3. Drag in a Destroy node and place it to the right.
  4. Set its Target to other.
  5. Drag from the exec pin on the right of On Overlap to the exec pin on the left of Destroy. A wire connects them.
  6. Drag in Add To Variable. Set Variable to score and Amount to 10.
  7. Wire Destroy → Add To Variable.

Show the score

The score variable already exists — Blank 2D ships with it. Now put it on screen.

  1. Back on the Scene tab, press + above the Hierarchy to add an entity.
  2. Set its Type to bitmapText.
  3. Set Layer to UI.
  4. Position it at X 40, Y 36.
  5. Set Origin X and Y to 0 so it anchors from its top-left corner rather than its centre.
  6. Add the behaviour bindText.
  7. Set its template to SCORE {score}.

Anything in braces is replaced with that variable's live value. The text updates the instant the variable changes — you never refresh it from the graph.

Play it

Run into a coin. It should vanish and the score should jump by 10.

If the coins do nothing

  1. Open the console with F12. Anything prefixed [gcs] is the engine telling you what it skipped.
  2. Check both tags are spelled exactly as the node expects.
  3. Check both entities have physics enabled — overlap needs a body on each side.
  4. Check the wire actually connects. An unwired event runs nothing at all.
  5. Check Tag A is the player and Tag B is the coin, matching the Destroy target.

Next: something that can kill you.