How to stop vibrating during gameover?

I’m using ARCADE for MakeCode Arcade.

< Kitronik ARCADE for MakeCode Arcade – Kitronik Ltd>

I added a controller extension to the following game, calling the vibration method only when the player hits an enemy or item.

However, when the game is over, it automatically starts vibrating, and it continues until the player presses A to turn off the dialog.
I would like to stop this.
I don’t know how to do this because the vibration on game over is not implemented in ‘main.ts’.
Does anyone know how to do this?

2 Likes

Solved!

When the life reaches zero, it transitions to the game over screen.
In that case, the specified vibration time was not valid in some cases.
Changed to vibrate on the collision event only when the life is 1 or more.

before

sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
    otherSprite.startEffect(effects.warmRadial, 100)
    otherSprite.destroy()
    info.changeLifeBy(-1)
     controller.vibrate(20)
})

After

sprites.onOverlap(SpriteKind.Player, SpriteKind.Enemy, function (sprite, otherSprite) {
    otherSprite.startEffect(effects.warmRadial, 100)
    otherSprite.destroy()
    if (info.life() > 1) {
        controller.vibrate(20)
    }
    info.changeLifeBy(-1)
})
4 Likes