0
I need to develop a game using HTML 5 and Javascript with the game inside a canvas
.
I created a game opening screen and after that click on play it directs to another screen. I called this way the event click
document.getElementById('canvas').addEventListener('click', verificaClick, false);
Where canvas
is the id of my canvas and verificaClick
the function that sends to the next step according to the selected option because I have the options "play", "how to play" and "credits".
If I click play it directs to a page where I choose the "stage" or "stage" of the game I want to play, more or less like Candy Crush.
My problem is that the canvas redesigns everything right, however remains the click event of the first part of the game, the first drawing of the canvas. I am redesigning, erasing the context and redesigning, but it remains the same click on the positions of the first "buttons" I drew.
Is correct the section where I call the click event?
document.getElementById('canvas').addEventListener('click', verificaClick, false);
If not, how should I do it; Put multiple contexts and add the event in context? How would I do that?
I edited your question using code formatting instead of bold (in the editor, the button
{}
does so). But I don’t quite understand the problem. You want to simply remove Event Listener?– bfavaretto