[Resolved] When game restarts last scene images don't load

HI Everyone,

This is my first post and I am brand new to programming and Corona. I have been working my way through tutorials and am trying to practice my skills by building a simple linear game. It’s basic and along the lines of a choose your own adventure book. It’s working well until I try to restart the game. The first time that you click through it works perfect, and when your directed back to the main screen (to try again) it works again except for I either have the images from the last scene of the game stay on the screen the whole second play through or they disappear completely not returning when you reach the end screen.

I’ve read and tried a lot of different things, please help…

Here is the code for the restart function:

function restart(event)
local function removeText ()
yourDeadGroup:removeSelf()
end

yourDead:removeEventListener(“tap”, restart)
main()
end

Note: I have rewritten this code 15x (at least), so this is just the basic of it. I tried using transitions, timers, etc.

All responses are greatly appreciated! [import]uid: 170524 topic_id: 30334 reply_id: 330334[/import]

Sorry, I didn’t realize I still had the function left in there. This is the cleaned up code

function restart(event)
if event.target.name = “yourDead” then
yourDeadGroup:removeSelf()
yourDeadGroup = nil
end

yourDead:removeEventListener(“tap”, restart)
main()
end [import]uid: 170524 topic_id: 30334 reply_id: 121526[/import]

you only remove the group and not the inserted Display Objects (e.g. images,…) [import]uid: 98393 topic_id: 30334 reply_id: 121532[/import]

Can you expand please because I thought that’s what the following code did;

yourDeadGroup:removeSelf()
yourDeadGroup = nil [import]uid: 170524 topic_id: 30334 reply_id: 121536[/import]

I figured it out and you were right! Thank you, I discovered that I had a bad habit of naming my images the same as the function. As soon as I renamed the image than removed the group this seemed to work.

Thank you! [import]uid: 170524 topic_id: 30334 reply_id: 121540[/import]

Sorry, I didn’t realize I still had the function left in there. This is the cleaned up code

function restart(event)
if event.target.name = “yourDead” then
yourDeadGroup:removeSelf()
yourDeadGroup = nil
end

yourDead:removeEventListener(“tap”, restart)
main()
end [import]uid: 170524 topic_id: 30334 reply_id: 121526[/import]

you only remove the group and not the inserted Display Objects (e.g. images,…) [import]uid: 98393 topic_id: 30334 reply_id: 121532[/import]

Can you expand please because I thought that’s what the following code did;

yourDeadGroup:removeSelf()
yourDeadGroup = nil [import]uid: 170524 topic_id: 30334 reply_id: 121536[/import]

I figured it out and you were right! Thank you, I discovered that I had a bad habit of naming my images the same as the function. As soon as I renamed the image than removed the group this seemed to work.

Thank you! [import]uid: 170524 topic_id: 30334 reply_id: 121540[/import]