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.scale.setTo(init_station_scale);
//station(middle anchor point).
station = game.add.sprite(750,195,"station");
station.anchor.setTo(.75,.75);
station.scale.setTo(init_station_scale);
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.anchor.setTo(0.5);
hint.animations.add("anim");
hint.animations.play("anim",15,true);
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)
initBullet();
else{
if(flagGameover){
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?