glass22 Posted December 20, 2013 Share Posted December 20, 2013 Hi, I'm trying to load a bunch of sprites on screen, then update them but am getting the error Maximum call stack size exceeded I've made it as simple as possible and still get the error function update(){ badGuyArray[0].update();} obj.update = function() { }; even with this it's still occuring Link to comment Share on other sites More sharing options...
rich Posted December 20, 2013 Share Posted December 20, 2013 I don't understand what obj.update = function is there for? Link to comment Share on other sites More sharing options...
glass22 Posted December 20, 2013 Author Share Posted December 20, 2013 Hi, Obj.update is just a function attached to my badguyObject, the object is created as obj, then returned to a createBadGuy function as a value. var BadGuy = function(){ var current = baddies.create(game.world.randomX, game.world.randomY, "bad"); var obj = SpriteBase(badSpeed, badHits, current); obj.update = function() { //var move = accelerateToObject(this.unit, Player.unit, this.speed, this.speed * 2, this.speed * 2); }; badGuyArray.push(this); return obj;}; Link to comment Share on other sites More sharing options...
glass22 Posted December 20, 2013 Author Share Posted December 20, 2013 Sorry realised my mistake! Link to comment Share on other sites More sharing options...
inductible Posted December 20, 2013 Share Posted December 20, 2013 The old 'recursive function call death loop' - you likely registered 'this' with itself in bad guys array? Update called update called update etc. Link to comment Share on other sites More sharing options...
glass22 Posted December 21, 2013 Author Share Posted December 21, 2013 Hi, No the issue was here badGuyArray.push(this);return obj; I should of been pushing obj, this was a function reference and not an object reference Link to comment Share on other sites More sharing options...
Recommended Posts