Jump to content

Display a variable from external js


Alierea
 Share

Recommended Posts

 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

 Share

  • Recently Browsing   0 members

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