pxt-calliope/docs/reference/game/set-score.md
Juri Wolf 5f7a8e5301
Updates for V4 (#197)
* update yotta defaults for 16kb devices

* refactor deprecated blocks

* updates for button events

* update button events

* update refference

* update docs

* update docs

* update button event blocks

* update docs

* update block id
2022-08-10 09:36:19 -07:00

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

See Also

score, add score, start countdown