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

Lifecycle events #18

Closed
czyzby opened this issue May 29, 2016 · 8 comments
Closed

Lifecycle events #18

czyzby opened this issue May 29, 2016 · 8 comments
Assignees

Comments

@czyzby
Copy link

czyzby commented May 29, 2016

Currently it's impossible to register lifecycle events or post Runnable instances. The application implementation should invoke all posted runnables during rendering.

@soywiz
Copy link
Contributor

soywiz commented May 30, 2016

I think this part could be totally generic if libGDX provided an Application adapter for this.

@soywiz soywiz self-assigned this May 30, 2016
@czyzby
Copy link
Author

czyzby commented May 31, 2016

You're right, but it isn't the first time LibGDX API isn't as clean as it could be, unfortunately. ;)

@soywiz
Copy link
Contributor

soywiz commented May 31, 2016

I will create an adaptor class, but I will keep it here. Maybe we can PR libGDX suggesting to include it in its main codebase.

soywiz added a commit that referenced this issue May 31, 2016
- Created a generic GdxApplicationAdapter
- Supported postRunnable + *LifecycleListener methods? Test required.
@soywiz
Copy link
Contributor

soywiz commented May 31, 2016

Fixed? When are Runnable supposed to execute? Before rendering? After rendering? Since there were no removePostRunnable I suppose they are executed just once

@czyzby
Copy link
Author

czyzby commented May 31, 2016

Yes, they are executed once and removed from the queue. I think they're usually executed before rendering.

Keep in mind that runnables can post other runnables (which can post other runnables, and so on) - it might make sense to avoid using a Queue. If I'm correct, GWT copies the runnables collection (if any runnables are present) before execution and clears it, so any extra posted runnables are not executed on the same frame. An endless loop due to runnables posting does seem like a programmer's error rather than framework's fault, but I think preserving the original LibGDX behavior is pretty important.

soywiz added a commit that referenced this issue May 31, 2016
- Proper postRunnable supporting executing in several frames
@soywiz
Copy link
Contributor

soywiz commented May 31, 2016

Check wether this test represent the expected behaviour:
818bc81#diff-e759478f1c1ce48be118e008744fc3cdR46

@czyzby
Copy link
Author

czyzby commented Jun 1, 2016

Yes, I think this is how it should work - or at least how it will work on GWT and LWJGL.

@soywiz
Copy link
Contributor

soywiz commented Jun 1, 2016

Cool. I'm closing it.

@soywiz soywiz closed this as completed Jun 1, 2016
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

No branches or pull requests

2 participants