can anyone please tell me that if i collide with a wrong answer in my multiple choice question, how can i make it loose one life and then when 3 lives are lost, just display end game. i have attached my image and code of game.
/*
This should be in your create() scene
*/
let correctAnswer = 4; // your correct answer
let lifePoints = 3; // your life points
let answerOne = this.add.sprite(0,0,"button").setInteractive(); // your answer button
answerOne.answer = 12; // button answer
answerOne.on("pointerup",()=>{
if(lifePoints <= 0)
endGame() // your end game function if life point <= 0
if(answerOne.answer != correctAnswer)
//if answer incorrect decrease life points
lifePoints--;
});
You can also create button class if you want, or just create buttons by my example as much as you need.
End game function can be like
function endGame(){
this.scene.start("endGameScene"); // start your end game scene
}