pxt-common-packages
Version:
Microsoft MakeCode (PXT) common packages
48 lines (33 loc) • 1.01 kB
Markdown
Change the number of lives for the game player up or down by this amount.
```sig
info.changeLifeBy(0)
```
The number of lives is increased by adding the change value when it is greater than zero (positive). If the change number is less than zero (negative), the life count is reduced by the value of the change number.
## Parameters
* **value**: a [number](/types/number) to change the life count by. Positive numbers add life and negative numbers reduce life.
## Example #example
Add `20` to the life count when the player reaches `10000` points.
### Single player
```blocks
let giveLives = true
if (info.score() > 9999) {
if (giveLives) {
info.changeLifeBy(20)
giveLives = false
}
}
```
```blocks
let giveLives = true
if (info.player2.score() > 9999) {
if (giveLives) {
info.player2.changeLifeBy(20)
giveLives = false
}
}
```
[](/reference/info/set-life),
[](/reference/info/life)