Jump to content

Phaser time


arun
 Share

Recommended Posts

If you're using Phaser time then it will probably be (never used it myself so I might be wrong) a certain increasing value that can be used to measure how much time elapsed since a certain event. You don't really care about the initial value - all you need to know it's displayed in milliseconds and it increments accordingly. 

http://phaser.io/docs/2.4.6/Phaser.Time.html#now

So at a certain point in your code you could say:

var shootTime = game.time.now; 

Later in code you could check if a certain amount if time elapsed like this (checks if 1000 milliseconds have passed and does something):

var mSeconds = 1000;

if( game.time.now > (shootTime + mSeconds)){

//do stuff

}

or 

var shootTime = game.time.now + 1000;//stores the current time + 1000 milliseconds

if(game.time.now > shootTime){

//do something

}

 

Like I said, you took those two lines out of the context so I can't really be sure to what those variables are pointing. 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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