how to stop app from 'stalling'

Monkey Forums/Monkey Programming/how to stop app from 'stalling'

slenkar(Posted 2012) [#1]
I dont have a smartphone I can use, but some people were saying it was best to load in resources in the main loop or the phone will think the program has crashed if it remains unresponsive for too long.

So when Im saving my game it remains unresponsive for about 20 seconds which is understandable, but I just wondered if there is a way of inserting some code to keep the phone or pc updated, like OnUpdate does


matty(Posted 2012) [#2]
Just a thought -

20 seconds is a long time to wait on a phone - that must be a lot of data...what happens if the user receives a phone call in that time?

I don't know what your game is, but is there some other way of storing the data, perhaps with less precision or by some other means that doesn't involve saving specific game data but rather a 'code' that lets the load sequence build an equivalent state from scratch?


skid(Posted 2012) [#3]
20 seconds to save your game is not understandable, it's incomprehensible. I agree you need to rethink your strategy.


Paul - Taiphoz(Posted 2012) [#4]
Yeah that is long.

Are you saving more than one file , maybe you could condense your save to a single file.


dawlane(Posted 2012) [#5]
@slenkar: I do all my data initialisation in the OnUpdate() method. I have a global integer variable that I use for testing various states of the application. Here's a bit of code that I'm using in a game I'm writting.

In the OnUpdate method.


My Initialised code

The method I'm using for timing events is a combination of integer bit flag for trapping events (the "t" in t0_general) and an array to store the millisecond to that event interval (the "b" in b0_general is the array index). The number after the "t/b" indicates the bit/index position.

In my OnRender method I just test to see if that bit (GS_INITIALISE) is set and draw a splash screen.

20 seconds is a long time to wait on a phone - that must be a lot of data...what happens if the user receives a phone call in that time?
It's amazing I was just thinking of that type of situation last night. My solution would be to use a Int variable as a status flag and unset various bits to signify if a load/save had completed successfully. If say the application was suspended for any reason it would be just a case of testing these bits when the application was resumed and continue loading the data from the beginning of the interrupted load/save file.


slenkar(Posted 2012) [#6]
hmm im making a strategy/rpg game, maybe I dont need to keep track of every limb of every character hehehhe


NoOdle(Posted 2012) [#7]
maybe I dont need to keep track of every limb of every character hehehhe


LOL no wonder it takes so long!


dawlane(Posted 2012) [#8]
hmm im making a strategy/rpg game, maybe I dont need to keep track of every limb of every character hehehhe
LOL. You may have to if your targeting mobile devices. Even more so for the newer apple variety gives me a head ache just thinking of those.