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

 Share

  • Recently Browsing   0 members

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