pxt-calliope/docs/reference/game/remove-life.md

676 B

remove Life

Decrease the number of lives remaining by some amount.

game.removeLife(0)

The life count in the game is decreased by the number of lives you say. If the life count reaches 0 when these lives are removed, then the game is over.

Parameters

  • life: a number to remove from the count.

Example #example

Take away 20 lives count if the player's score reaches 10000 points.

let giveLives = true

if (game.score() > 9999) {
    if (giveLives) {
        game.removeLife(20)
        giveLives = false
    }
}

See also #seealso

set life, add life