I am not ajavascript or phaser expert, I just got stuck with this problem. I'll try to explain it. In this game; is a 21 second timer in all this: which starts AFTER a beginning 3 second animatiton.

var maxTime = 21; //in SECOND

There is a wheel (station) that spins over and over (loops) and scales up and down:

var init_station_scale = 0.5;
var scale_station = 0.40;

When the game resets the station (wheel) resets

function resetGame(){


//station(middle anchor point).

  station = game.add.sprite(750,195,"station");
  station.animations.add("anim"); //Init animations
  station.animations.play("anim",15,true);  //play Animations "anim" with 30fps, loop true

Not to confuse you, but there is a lot going on in this 21 seconds, such as:

//hint (this is hooked up with the station (wheel)

      hint = game.add.sprite(game.world.centerX+50,game.world.centerY+100,"hint");
  hint.visible = false;

Playing a 3 second animation that only plays once at the very beginning of the game (including if game resets); also starting .play ("anim",15, true); //(above (station/wheel) code and looping it)

after that 3 second animation; console.log("FINISH ANIMATION and ADD TIMER"); TIMER is referring to the 21 second timer

timerEvent = game.time.events.add(Phaser.Timer.SECOND * maxTime,  moveToEndGame, this);  //(also the 21 second timer)

function moveToEndGame(){
  console.log("TIMER END");
  var twn = game.add.tween(bg).to({alpha:0},tween_speed,"Linear",true);
  twn.onComplete.addOnce(function(){flagGameover = true;},this);

 if(!flagGameover && !star.visible && idx_bullet < bullet_array.length)
          console.log("GOTO GAMEOVER");
          window.location = "../EndGame.html";


Everything works up until the end of the 21 second timer, but station/wheel keeps spinning creating an 'infinite loop" So there is nothing to stop the 'loop in the station" after the 21 second timer finishes. Coder left out a line that would do that? Some line of code needs to be added to that last block of code (or somewhere else?)to stop the loop on the station timed with the end of the 21 second timer. I think????

Or some kind of javascript kill switch: i.e. stop all javascript then go to endgame.html

Anyone know the answer?


1 Answer 1


I found out what it was.

It was missing a callover, as in:

var callGameover = false;


      if(callGameover == false){ 
        callGameover = true;
         console.log("GOTO GAMEOVER");
         window.location = "endgame.html";

I didn't know that was enough to cause an "infinite loop" but apparently it was. Put the above in and loop gone!


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .