arun

Phaser time

Recommended Posts

dear friends,

I don't understand the  2 lines of code below.  please help me

if (this.time.now > shootTime)

{

nut = nuts.getFirstExists(false);

}

 

Share this post


Link to post
Share on other sites

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. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.