pxt-calliope/docs/reference/game/set-score.md
Sam El-Husseini e3975e65e5 pxt-microbit Accessibility PR ()
* Accessibility changes
2017-09-07 13:42:08 -07:00

617 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.onButtonPressed(Button.B, () => {
    basic.showNumber(game.score())
    game.setScore(0)
})
input.onButtonPressed(Button.A, () => {
    game.addScore(1)
})

See Also

score, add score, start countdown