0x_Anakin
0x_Anakin

Reputation: 3269

Uncaught RangeError: Maximum call stack size exceeded canvas requestAnimFrame

I'm currently working on a javascript canvas 2D game engine and I'm having some issues regarding requestAnimFrame. It seems to me that I'm doing it correctly but after some time I get the following error (Uncaught RangeError: Maximum call stack size exceeded)

You can take a look of the source here: http://snipt.org/vxij1

Upvotes: 0

Views: 3586

Answers (1)

jfriend00
jfriend00

Reputation: 707836

My guess is that this line:

requestAnimFrame(this.mainGameLoop());

should be this:

var self = this;
requestAnimFrame(function() {self.mainGameLoop()});

so that your callback is called later as a callback, not executed immediately.

Upvotes: 1

Related Questions