Jump to content

review please!


dthrasher90
 Share

Recommended Posts

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

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 by Greeny
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...