Fix remove life animation causing microbit stuck (#2314)
On the real microbit board, if the program execute other game blocks while the remove life animation is playing, it would cause strange behavior or even make the game stuck.
This commit is contained in:
@ -210,7 +210,8 @@ namespace game {
|
||||
//% blockId=game_remove_life block="remove life %life" blockGap=8
|
||||
export function removeLife(life: number): void {
|
||||
setLife(_life - life);
|
||||
if (!_paused)
|
||||
if (!_paused && !_backgroundAnimation) {
|
||||
_backgroundAnimation = true;
|
||||
control.inBackground(() => {
|
||||
led.stopAnimation();
|
||||
basic.showAnimation(`1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0
|
||||
@ -218,8 +219,10 @@ namespace game {
|
||||
0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
|
||||
0 1 0 1 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0
|
||||
1 0 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0`, 40);
|
||||
_backgroundAnimation = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Increments the level and display a message.
|
||||
|
Reference in New Issue
Block a user