dthrasher90 Posted April 24, 2017 Share Posted April 24, 2017 function kickoff(){ newBallSpotx=220; console.log("kickoff results in touchback"); var ct = game.add.sprite(newBallSpotx, 220, 'ct'); ct.scale.setTo(0.03); game.physics.arcade.enable([ct]); } function checkScored(footballx){ scored == false; if(scored == true){ kickoff(); } else { passPlayLeft(); newBallSpotx = footballx; console.log("no score"); } } function passPlayLeft() { checkScored(); var ct = game.add.sprite(newBallSpotx, 220, 'ct'); ct.scale.setTo(0.03); var QBx = ct.x - 20; var QBy = ct.y; var qb = this.game.add.sprite(QBx, QBy, 'qb'); qb.scale.setTo(0.02); Link to comment Share on other sites More sharing options...
dthrasher90 Posted April 24, 2017 Author Share Posted April 24, 2017 I am trying to simulate a kick off(no moving sprites) up to the first play call. Is there a better way? I keep on getting maximum call stack errors with checked score set to false, it works with true. Link to comment Share on other sites More sharing options...
Greeny Posted April 24, 2017 Share Posted April 24, 2017 (edited) You getting maximum callstack error because if "scored" is false, then you have infinity loop. passPlayLeft() -> checkScored -> "scored" !== true so "else" condition and passPlayLeft() again. Edited April 24, 2017 by Greeny Link to comment Share on other sites More sharing options...
dthrasher90 Posted April 24, 2017 Author Share Posted April 24, 2017 Ahh that explains the loop Link to comment Share on other sites More sharing options...
Recommended Posts