Values and switches
In Expert mode, every copy of a sprite has ten numbers and eight switches of its own, to remember things like health or “already counted”.
What they are
Every copy of a sprite carries its own little notebook. In it are ten numbers, Value A to Value J, and eight on/off switches, Switch 0 to Switch 7. All start at 0 and off.
They are per copy. Ten bats can each have a different Value A. That is what makes them different from the score or a counter, which there is only one of.
Values and switches appear in Expert mode. Switch mode at the top to see them. Rules you already wrote keep working in any mode.
What to use them for
| A value | Each baddie's own health. How many times a crate has been hit. Which lane a car is in. |
|---|---|
| A switch | Remembering “already counted” so a coin does not score twice. Whether a door is open. Whether the bird has crashed, as in Wing It. |
How to give a baddie its own health
- Switch to Expert at the top.
- In the Events tab, click + New event, choose Start of level.
- In the Bat cell, add Set a value: Value A to 3.
- Make a second rule: Bullet collides with Bat → Subtract 1 from Value A of Bat, Destroy Bullet.
- Make a third: Value A of Bat ≤ 0 → Destroy Bat.
Only the bat that was hit loses a point, because collisions pick the copies that touched.
The rules
Set a value Add to a value Subtract from a value Compare a value Number each object (spread a value)
Turn a switch on Turn a switch off Flip a switch Switch is on Switch is off
Number each object gives every copy a different number: 0, 1, 2… Handy for telling ten identical blocks apart. In a formula, Value("Bat", "A") and Flag("Bat", 0) read them. See Values and switches on objects and Sprites: values and switches.