!CLOSED!
Hey i've been messing around with Objects in JavaScript and i've come to a problem:
function Game(name, canvas, width, height, fps)
{
this.name = name;
this.canvas = document.getElementById(canvas);
this.ctx = this.canvas.getContext('2d');
this.width = width;
this.height = height;
this.fps = fps;
}
Game.prototype.gameloop = function()
{
//Clear Screen
this.canvas.width = this.canvas.width;
//Update
//Update();
//Draw
Draw(this.ctx);//this is now pointing at 'Game'
};
Game.prototype.start = function() {
this.interval = setInterval(this.gameloop.bind(this),this.fps);
};
I can't figure out why in this case the 'this' keyword isn't pointing at 'Game'
Any suggestions?