Heart Example

8246
8247
16
17

Arrow keys to move. Touching the spikes removes a heart. Touching the apple restores a heart.

The Player object stores a health value in a Number block. Touching the heart increments the health value, but touching a spike decrements it.

The Hearts object has an animation with 6 frames, eith each frame representing a health level (frame 1 has 1 heart, frame 2 has 2 hearts, and so on)

The player object sends a Message to the Hearts object when the health value changes. The heart's Mailbox is connected to an Animation block, so the incoming message value is used to select the correct animation frame.

Editor