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

Introduce UpdateFrame event #1034

Merged
merged 1 commit into from
May 7, 2017
Merged

Introduce UpdateFrame event #1034

merged 1 commit into from
May 7, 2017

Conversation

mucaho
Copy link
Contributor

@mucaho mucaho commented May 8, 2016

This event replaces the EnterFrame event.
The EnterFrame event now triggers before the UpdateFrame event.

This is a potentially breaking change. While code may still work with binding to EnterFrame, it may introduce latency from previous / to next state update.

Could be useful for setting-up movement in response to input events before the state updates.
This is better than doing it after the state updates, which is already possible with ExitFrame, because there is added latency before the input is checked and after it is processed (up to 20ms in the default case).
Additionally, having input processing bound to the UpdateFrame does not guarantee it will be executed before the Motion updates, which also bind to an arbitrary execution order triggered by UpdateFrame.

  • Replaces all triggered callbacks of the EnterFrame event to be triggered by UpdateFrame instead.
  • Fixes (hopefully) all api docs to reflect the change.
  • Fixes documentation on Crafty's website to reflect the change.

@starwed
Copy link
Member

starwed commented May 28, 2016

This is a pretty large change. I don't think it's necessarily bad, but I'm also not sure how much an improvement it is. I guess trying it is the best way to see! :)

Could be useful for setting-up movement in response to input events before the state updates.

IIRC the way input events are handled in Crafty is a little weird -- they don't actually happen at a specific part of Crafty's own game loop, but rather are directly triggered by the browser events. (Possibly the way forward there would to be to have the event dispatchers add them to an internal queue which is processed once per cycle.)

@mucaho
Copy link
Contributor Author

mucaho commented Apr 12, 2017

Updated this PR.
One additional change is that the controls system listens to the "EnterFrame" instead of the "EnterFrameInput" event, since "EnterFrame" is the now triggered before the main "UpdateFrame" event.

This event replaces  the EnterFrame event.
The EnterFrame event now triggers before the UpdateFrame event.
Replaces all triggered callbacks of the EnterFrame event to be triggered
by UpdateFrame instead.
Replaces the "EnterFrameInput" event triggered for the control system by
the "EnterFrame" event, as this now serves to process user input.
@mucaho
Copy link
Contributor Author

mucaho commented May 7, 2017

This is a pretty large change. I don't think it's necessarily bad, but I'm also not sure how much an improvement it is. I guess trying it is the best way to see! :)

Alright, let's do this!

@mucaho mucaho merged commit b71d6e8 into craftyjs:develop May 7, 2017
@mucaho mucaho deleted the update_frame branch May 7, 2017 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants