LoCEngine.prototype.runGame = function() {
// Initiate our game loop
ctx.clearRect(0, 0, 800, 600);
this.drawScene(this.curScene);
if(this.gameRunning) {
window.setTimeout(Engine.runGame, 1000 / this.framerate);
}
}
LoCEngine is an experimental engine I've been building to learn the ins and outs of HTML5 Canvas gaming. Been a good time thusfar, until I've hit the gameloop. runGame is called over time, which clears the Canvas and calls the drawScene function.
LoCEngine instance is stored in variable Engine (not sure if using that in setTimeout is best practices...please advise)
It will correctly call this.drawScene for the first frame, but upon the Timeout (30 FPS) it throws an exception saying:
TypeError: this.drawScene is not a function
Not quite sure why...I'm sure it's just something about JS I haven't come across. Thank you in advance.