Gibbo
Gibbo

Reputation: 660

Show(), what to put here?

I understand that the show() method is used to bring the screen back to the front when the user re-opens the app or brings it to the foreground.

However, what should go here?

Lets say I have a bunch of objects, with textures attached and actively being rendered and constantly moving position.

If I say, hit the pause button, the hide() function gets called and I the initiate a new screen. Say I come back to the GameScreen, does libGDX/Box2d automatically take care of everything for me or do I have to make sure that I have some sort of code in the show() method?

Upvotes: 0

Views: 69

Answers (2)

Jeremy Scoggins
Jeremy Scoggins

Reputation: 954

Anything that needs to be stopped in hide() should be restarted if needed in show(). This could include music, background threads, etc. I use show() to refresh the data behind the screen, since I keep instances around to avoud garbage collection.

Upvotes: 1

ssantos
ssantos

Reputation: 16526

There's no need for you to do anything, unless you want to put here some specific initializations. For instance, show() method is a good place to start playing a background music for the recently showed scene.

Upvotes: 0

Related Questions