Variables and expressions

Scores, lives, high scores that survive a reload, and the little expression language.

5 min read

Variables are declared under Assets → Variables. Each has a name, a type and a starting value.

Persistence

Mark a variable persist and it is saved to the player's device and restored on load. That is how high scores work. The kits conventionally call it best.

Expressions

Number fields accept arithmetic, and any bare variable name is replaced by its value: score * 2, lives - 1, 100 + i * 60.

Showing them on screen

Add the bindText behaviour to a text entity and give it a template. Anything in braces is replaced live:

Template:  SCORE {score}   LIVES {lives}
Shows:     SCORE 1200   LIVES 3

The text updates the moment the variable changes — you do not need to refresh it from the graph.

Reacting to a change

The On Variable Changed event fires whenever a variable is written. Most game-over logic in the kits is a single such node wired to an If checking lives <= 0.