Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding GameTime. Time since app start that pauses with director. #101

Closed
wants to merge 3 commits into from

Conversation

funinvegas
Copy link
Contributor

getGameTime will return ms since app start, and won't increment when the app is paused.
Useful for replacing goog.now() calls or Date.now() calls for time path, while preventing pause-cheats.

Minor other fixes.

@funinvegas
Copy link
Contributor Author

This change also includes a change to node.js to skip updating hidden objects. The caller to update also doesn't force the dirty_ flag to 0 after calling update for two reasons. 1: update already did this. and 2: this allows the skip of hidden elements to be safer because they will still be dirty when they are ever shown again.

* Get Game Time
* Time since app start that does not advance while paused.
*/
lime.scheduleManager.GetGameTime = function () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase

@funinvegas
Copy link
Contributor Author

I'll make the recommended fixes and create another pull request tonight.

@tonistiigi
Copy link
Member

You can just commit your changes to the same branch and this page will pick it up.

@funinvegas
Copy link
Contributor Author

Per your request I tested delta vs getGameTime. they are off by about 460ms to start, probably because my delta function doesn't schedule itself early enough.

After that, pausing and resuming seem to cause a difference of about 2ms in delta's favor. Also, calls to lime.updateDirtyObjects() which I call on window resize while the pause screen is open seems to add 1-3ms to delta, and not to getGameTime.

Probably a matter of preference on which is "correct".

@tonistiigi
Copy link
Member

That is a problem. Not sure what causes the difference but maybe we should use a different technique then and sum up all the deltas in schedulemanager. getGameTime() would then return this sum + performance.timing.domComplete. If these numbers are not correct all the time you can't rely on them in your game.

@funinvegas
Copy link
Contributor Author

Ok, I can change it to also use sum.

Btw, I wouldn't be offended if you just don't want this change. I can move it out of director and into some other global for my local game. It doesn't have to be part of limejs if you don't like it.

…eTime() with my own global TD.getGameTime() and I now track this outside of limeJS.
@tonistiigi
Copy link
Member

Closing this now because there doesn't seem to be any getGameTime() related code left. Reopen when you have some.

@tonistiigi tonistiigi closed this Sep 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants