I have this source code:
var Game = function() {
var canvas = document.getElementById('world');
this.context = canvas.getContext('2d');
I use some functions to deal with this class:
Game.prototype.updateAll = function() {...}
and some another functions.
Now I want to use mouse functions ( click right , left …)
I think is need to add in my Game class something like that:
this.canvas.addEventListener("click", this.getmouse, false);
But the browser don’t show me anything …
How and where can be do this function in my class ?
From the code you posted,
Gamehas nothis.canvas. You defined a local variable withvar canvas, but you need to set theGamemember variablethis.canvas. If you want both, just follow your currentvar canvas = ...line withthis.canvas = canvas;.