menu buttons: home vs back and reloading the game

I have been developing for android 3.0 for awhile now and have noticed a few weird occurrences and I am not sure why they happen:

When i first load the game, the login screen loads fine (native.newInputfields, pictures, and login button). Now, if I were to push back (from the menu buttons) and load the game again, all the shows up are the two input fields. None of the pictures show up or the login button.

Even weirder, if I press where the login button SHOULD be, the pictures pop up for a second and it logs in.

but if I were to press home instead of back, the app will load exactly where it was left last time I loaded it.

I am trying to figure out a solution to the back button problem, but I am not sure exactly what is happening.

Can anyone help me out?

-Amanda

I can't tell from your question whether or not you mean you are using the back button to exit the game and reopen it, or if you are using it to return to the menu screen.

Could you please clarify?

I am hitting the back button on the device to exit the game.

And once I start the game again, nothing shows up but the native text boxes with a black background.

This happens every time.

I had a problem with this back in the day. Tom hooked it up with this code put this in your main lua.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
--------------------------------------------------------------------------------
-- Android "restart" Wakeup Code (forces a display update after 250 msec)
--
-- If applicationStart then fire a 250 ms timer.
-- After 250 ms, changes the Alpa value of the Current Stage (group)
-- This forces a display update to wake up the screen
-------------------------------------------------------------------------
local function onAndroidSystemEvent( event ) 
        
        local timerEnd = function()
                local t = display.getCurrentStage()
                t.alpha = 0.9           -- force a display update
                timer.performWithDelay( 1, function() t.alpha = 1.0 end ) -- wait one frame
        end
        
        -- Start timer if this is an application start event
        if "applicationStart" == event.type then
                timer.performWithDelay( 250, timerEnd )
        end
end
 
-- Add the System callback event if Android
if "Android" == system.getInfo( "platformName" ) then
        Runtime:addEventListener( "system", onAndroidSystemEvent )
end
------------------------------------------------------------------------

Awesome! Just added it and it seems to work!

thanks so much!

-Amanda

Your welcome glad I could help.

views:1508 update:2011/10/7 17:24:19
corona forums © 2003-2011