Pardon the mess, Play My Code is in beta!

READY TO PLAY?
CLICK TO LOG IN!

sign up - lost password

getTime

getTime()

Returns how long the game has been running, in milliseconds.

gameTime = getTime()

What is special about getTime is that it takes into account pausing the game player. It also only updates between frames, and never during one.

It works like this so animations that use getTime will work seamlessly, across a frame, on following frames. For example the Timer class uses getTime internally, so animations used with the Timer class will work fine across multiple frames.

Getting the real time

As getTime is designed for game time, not actual real time, it isn't useful for some timing operations. For example it only updates between frames, and not during one.

To get the actual time you can use the Time class, and call it's 'toMilliseconds' method.

realTime = new Time().toMilliseconds()

See Also