VahidHoseini
VahidHoseini

Reputation: 505

How to run my code when I get back to previous screen in libgdx?

As you know this is LibGDX Lifecycle

           __________________________________
           |         ____       ____        |
           V         V   |      V  |        |
show --> resume --> resize <-- render --> pause --> hide --> dispose
           |          |          ^          ^
           |__________|__________|__________|

which is explained here : https://stackoverflow.com/a/21063460/5733853

I want to run my cods when I get back to previous screen:

MainmenuScreen.java --> GameScreen.java
         ^                     |
         |------------i am here|  

pause,resume,resize is clear that not work in this case and in render the codes run non stop and I got wrong answer so any help would be greatly thankful.

Upvotes: 1

Views: 158

Answers (1)

Tekkerue
Tekkerue

Reputation: 1517

If MainmenuScreen and GameScreen are extensions of the LibGDX Screen class, it has a method called show() that is called when that screen becomes the current screen.

https://libgdx.badlogicgames.com/ci/nightlies/docs/api/com/badlogic/gdx/Screen.html#show--

Upvotes: 1

Related Questions