I start with
local background = display.newImage("myscreen.png")
menuScreen:insert( background )
and later, when I no longer need or want that backgroup, I use:
menuScreen:remove(background)
So far so good.
Now I'm adding in the instruction pages. In the initial event that calls the first instruction page I do:
1 2 3 | menuScreen:remove(background) tutorialPage1 = display.newImage("tutorialPage1.png") tutorialScreen:insert(tutorialPage1) |
and add an event listener for page turns. One possibility in the event listener is that the user wants to go back to the main screen. My code sorta looks like this:
1 2 3 4 5 6 | tutorialScreen:remove(tutorialPage1) if(user wants to go back to main screen) then Runtime:removeEventListener( "touch", tutorialTouch ); menuScreen:insert( background ) gotoMainMenu(event) end |
The problem is that the image described by "tutorialPage1" never goes away, and "background" never appears.
How come?
Thanks,
Sean.
I am having some similar problems which we suspect are to do with garbage collection and elements hanging around. This is, apparently, a common problem with iPhone app and you need to almost force a item to be removed at times.
However, I can't for the life of me find the syntax to do this :-)
I have a couple of layers of buttons and images (each forming a page). I place the button images without the tap event, then turn it on when the page is shown ... then off when the page is left. All well and good. However, the buttons are being left active (I am also using removeEventListener).
Any ideas?
Cheers
Gary
Well, I still don't understand why it doesn't work. However, after scouring the forum, I finally ran across something that solved the problem.
When the user wants to go back to the main menu, I use the following code (one line added from original):
However, I still don't understand the relationship to screens/groups and what's displayed onscreen. Is there any good explanation of that somewhere?
Thanks,
Sean.