2016-08-10 22:10:40 +02:00
|
|
|
# Set Score
|
|
|
|
|
|
|
|
Sets the current score.
|
|
|
|
|
|
|
|
```sig
|
|
|
|
game.setScore(1)
|
|
|
|
```
|
2019-12-02 05:58:26 +01:00
|
|
|
## Parameters
|
2016-08-10 22:10:40 +02:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
* a [number](/types/number) that represents the new score.
|
2016-08-10 22:10:40 +02:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## Examples
|
2016-08-10 22:10:40 +02:00
|
|
|
|
|
|
|
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
|
2020-02-20 17:00:11 +01:00
|
|
|
input.input.onButtonEvent(Button.B, ButtonEvent.Click, () => {
|
2016-08-10 22:10:40 +02:00
|
|
|
basic.showNumber(game.score())
|
|
|
|
game.setScore(0)
|
|
|
|
})
|
2020-02-20 17:00:11 +01:00
|
|
|
input.input.onButtonEvent(Button.A, ButtonEvent.Click, () => {
|
2016-08-10 22:10:40 +02:00
|
|
|
game.addScore(1)
|
|
|
|
})
|
|
|
|
```
|
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
## See Also
|
2016-08-10 22:10:40 +02:00
|
|
|
|
2019-12-02 05:58:26 +01:00
|
|
|
[score](/reference/game/score), [add score](/reference/game/add-score), [start countdown](/reference/game/start-countdown)
|