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

601 B

add Life

Increase the number of lives remaining by some amount.

game.addLife(0)

The life count in the game is increased by the number of lives you say.

Parameters

  • life: a number to add to the life count.

Example #example

Add 20 more lives to the life count if the player's score reaches 10000 points.

let giveLives = true

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

See also #seealso

set life, remove life