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:
Leo authored and Peli de Halleux committed 2019-09-03 13:30:40 -07:00
1 parent 61b3bd2833
commit 82386e8144
1 file changed
+4 -1
+4 -1
View File
@@ -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,7 +219,9 @@ 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;
});
}
}
/**