I am having issues with the HP system not working in the electric mouse exercise, I have followed the code hints and replicated the code but still not subtracting 1 point each time that both of the characters attack in the attack mode. I am around step 18.
If anybody knows where the issue is would be really appreciated. Thank you.
Please see my code below: Click here
gameState.attackButton.on(‘pointerup’, () => {
this.pauseIdle()
if (game.input.enabled) {
// Add your code for Electric Mouse attacking below:
let randomMove = Math.floor(Math.random() * 3);
if(randomMove === 0) {
// both attack
gameState.information.text = `Ouch! You both lost 1 HP`;
gameState.playerMove.text = 'Attack!';
gameState.computerMove.text = 'Attack!';
gameState.player.health -= 1;
gameState.computer.health -= 1;
gameState.computerHealthBar.text = `Hp: ${gameState.computer.health}`;
gameState.playerHealthBar.text = `Hp: ${gameState.player.health}`;
gameState.player.sprite.anims.play('playerAttack');
gameState.computerSprite.anims.play(gameState.computer.name + 'Attack');
}
}
});