Giter Site home page Giter Site logo

Comments (3)

crykn avatar crykn commented on May 9, 2024

The initial goal of splitting the screen creation into the constructor and the create() method was to allow deferring the initialization of screens. This can come in handy if you are using a loading screen to load your assets: At the start, you can create your screen (and do stuff in its constructor), even when your assets aren't loaded yet; create() is then only called when your assets are already loaded (either via the loading screen calling ManagedScreen#initializeScreen() (which internally calls create()) or automatically when the screen is first shown (by default create() is called right before the screen is first shown)).

As I've stated here, as the library has become bigger this has turned out to be somewhat confusing for new users and I'm not really sure whether this couldn't be handled in a better manner in future releases. Maybe it'd make sense to combine it with a dependency injection system (so you wouldn't have to hand over everything via the new screen's constructor), but that is a problem for another day.

To get back to your question: if your stuff was in libGDX's show() method, it can stay there in libgdx-screenmanager's show() method. Both of those are called whenever the screen is shown. On the other hand, libgdx-screenmanager's create() method is only called once (!) and can be seen as a replacement for the screen's constructor.

All of this is also detailed here and here in the wiki, so be sure to check that out too.

from libgdx-screenmanager.

wangdong20 avatar wangdong20 commented on May 9, 2024

Is it required to call super.show() before the code block in show() in libgdx-screenmanager system?
After reading the code from ManagedScreen, I think it is required.

from libgdx-screenmanager.

crykn avatar crykn commented on May 9, 2024

Yes, you should.

from libgdx-screenmanager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.