Alierea Posted August 21, 2016 Share Posted August 21, 2016 updateTimer:function(){ timerSeconds ++; secondsLeft = gameSeconds - timerSeconds; // Display in min:seconds displayMin = Math.floor(secondsLeft/60) % 60; displaySec = Math.floor(secondsLeft) % 60; if (displayMin < 10) { displayMin = "0" + displayMin; } if (displaySec < 10){ displaySec = "0" + displaySec; } //myTime.setText("time now" + this.timerSeconds); // change the time text myTime.setText(displayMin + ":" + displaySec); // change the time text if (displayMin == 0 && displaySec == 0){ this.game.state.start('Loser'); } Hello there. I am new to phaser. Here is a snip of code from a simple game that I am trying to build. I tried to set up a timer when counting down to zero, the game then will display a lose screen. My question is how can I access the reaming time in this timer on a another different JS file. All the variables are global.Which format should I use? I tried this way but it did not work. I just get stuck. var displayTime = this.myTime; var disStyle = this.add.text(this.world.centerX-80, this.world.height-220, displayTime, disStyle); Link to comment Share on other sites More sharing options...
Recommended Posts