Hello,
I want to deal with application suspension issue in my app, for instance I want to make sure the app saves the hiScore and other game variables no matter what happen to the app ( for instance th user quit the app or receive a phone call). I found the code below (great Mobile Tuts) and was wondering this:
Do I need to put a similar code on each module (I am using Director) or can simply put that code in main? I think I will need to put that code on each module (menu, help, gameScreen,…) but I am not sure,
Thanks for any help.
Mo
[lua]----- main.lua -----
– hide the status bar
display.setStatusBar( display.HiddenStatusBar )
– setup a solid background
local background = display.newRect(0, 0, display.contentWidth, display.contentHeight)
background:setFillColor(191, 69, 66)
– create a function to handle all of the system events
local onSystem = function( event )
if event.type == “applicationStart” then
print(“start”)
elseif event.type == “applicationExit” then
print(“exit”)
elseif event.type == “applicationSuspend” then
print(“suspend”)
elseif event.type == “applicationResume” then
print(“resume”)
end
end
– setup a system event listener
Runtime:addEventListener( “system”, onSystem )[/lua] [import]uid: 49236 topic_id: 24615 reply_id: 324615[/import]
[import]uid: 52491 topic_id: 24615 reply_id: 99719[/import]