Jump to content

key timeDown question


DGW
 Share

Recommended Posts

Hi All,

 

I'm trying to work out when a key was pressed down from some change that happens on screen (ie find how long it takes to respond to the change). I record the time when the event happens and then compare to timeDown of a given key press.The docs say that timeDown is based on Game.time.now. So I presumed I would use Game.time.now to log the time of the change and compare to timeDown. However, from my timeDown values (very large) it looks as though timeDown is based on Date.now(), and so I should probably log the time of the change using Date.now().

 

Wanted to check if I'm missing anything here?

 

Thanks for any help.

 

best wishes, D.

Link to comment
Share on other sites

game.time.now seems to be more or less Date.now() : 

 

"An increasing value representing cumulative milliseconds since an undisclosed epoch.
While this value is in milliseconds and can be used to compute time deltas, it must must not be used with Date.now() as it may not use the same epoch / starting reference.
The source may either be from a high-res source (eg. if RAF is available) or the standard Date.now; the value can only be relied upon within a particular game instance."
 
 
But I don't get your problem : even though the values are high, if you always use game.time.now, then to calculate the elapsed time you should get the correct delta t no?
Link to comment
Share on other sites

Yeah, I think this is solved now. Being new to Phaser it seemed odd that it wasn't working as I expected so just wanted to make sure I wasn't missing something obvious. I think I'll end up using Date.now() when the change happens. I'll link a keydown event to a function and read Data.now() again when the function runs. That way I'll know that the timing is using the same functions.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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