Diddy & When Home Button is Pressed?

Monkey Targets Forums/Android/Diddy & When Home Button is Pressed?

Amon(Posted 2012) [#1]
During gameplay if a user presses the Home button what do I need to do in Diddy to handle this?

Will the game pause and return to where it left off?

Will I need to Null objects/lists and recreate?


Samah(Posted 2012) [#2]
I don't see how using Diddy makes a difference... this is what OnSuspend and OnResume are for. And yes, OnRender/OnUpdate are paused while the app is inactive.

You shouldn't need to recreate anything. All pressing home does is backgrounds the activity stack and jumps back to the home screen. Nothing gets deleted in your app's memory.

However, when your app loses the focus, the OpenGL context is destroyed. This means it needs to push all your images to video memory again. This is automatic when you call DrawImage; you don't need to load them again or do anything else.


Amon(Posted 2012) [#3]
Cheers for the info, Samah!


dragon(Posted 2012) [#4]
This is automatic when you call DrawImage; you don't need to load them again or do anything else.


But self created images are undefined?


I believe here is also a issue on iOs/Android:
if you start many programs and/or you have not enough mem, paused apps are auto closed - so you can lost settings and game state (next time this app is started from new)


AaronK(Posted 2012) [#5]
You also need to be aware that when your app goes into the background state it might very well be terminated by the OS. So if you want to give the user the ability to continue from where they were then you may need to save some state in OnSuspend.


Amon(Posted 2012) [#6]
I'm having problems with the whole thing on Android OS. I've been able to determine that I need OnSuspend/OnResume for each screen created with Didddy but also, as dragon states, self created images need to be saved and reloaded. I've tried but I still get a runtime error when dong this.

I'm doing something wrong anyway so before I continue with the rest of the game I better establish a way to handle this properly.