2016-08-10 22:10:40 +02:00
|
|
|
# Set Score
|
|
|
|
|
|
|
|
Sets the current score.
|
|
|
|
|
|
|
|
```sig
|
|
|
|
game.setScore(1)
|
|
|
|
```
|
|
|
|
### Parameters
|
|
|
|
|
2017-03-16 15:57:41 +01:00
|
|
|
* a [number](/types/number) that represents the new score.
|
2016-08-10 22:10:40 +02:00
|
|
|
|
|
|
|
### 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.
|
|
|
|
|
|
|
|
```blocks
|
|
|
|
input.onButtonPressed(Button.B, () => {
|
|
|
|
basic.showNumber(game.score())
|
|
|
|
game.setScore(0)
|
|
|
|
})
|
|
|
|
input.onButtonPressed(Button.A, () => {
|
|
|
|
game.addScore(1)
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
|
|
|
### See Also
|
|
|
|
|
|
|
|
[score](/reference/game/score), [start countdown](/reference/game/start-countdown)
|