pxt-calliope/docs/reference/game/set-score.md
2020-02-20 17:00:11 +01:00

663 B

Set Score

Sets the current score.

game.setScore(1)

Parameters

  • a number that represents the new score.

Examples

This program is a simple game. Press button A as much as possible to increase the score. Press B to display the score and reset the score.

input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
    basic.showNumber(game.score())
    game.setScore(0)
})
input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
    game.addScore(1)
})

See Also

score, add score, start countdown