Need Help With The Scenes.

I have put a button and it just stays there, this may be a " stupid " Question but I changed from another App program to corona, which seems to be amazing!!

So I’m a newbie here, however, when I press a button, I want that a new scene loads, like when you press “play” the game starts, something like that, just without the game, just the new scene…

So when I press a button, the new Scene shows up.

OK, give us some code to check out. It will really help us pinpoint the problem.

Without code, I can guess that the problem you have is that you’re not inserting your button into the scene’s ‘group’. If you insert it into the scene’s group, then the button will be cleaned up (along with the event listener too!) automagically when you do a “purgeScene”.

Here’s a snippet of my code to switch scenes:

[lua]

function scene:createScene( event )
     – This is the display group that all your stuff
     – should be in for this particular scene
     local group = self.view
     myButton = display.newImageRect(group, “graphics/background.png”, _W, _H )
     
     – The event listener function for our ‘myButton’ graphic!
     function DoStuff:tap(e)
          – First purge our current scene…
          storyboard.purgeScene(storyboard.getCurrentSceneName())
          – Now go to our next scene
          storyboard.gotoScene( “scr_MyOtherScene”, { effect=“fade”, time = 250} )
     end
     – Attach the Event listener function “DoStuff” to the “myButton” grpahic
     myButton:addEventListener(“tap”,DoStuff)
end

[/lua]

Storyboard can be a tricky beast. Don’t get discouraged, keep hitting us up for help and we’ll be there for you. Just remember, always insert any of your scene specific graphics into ‘group’ and it should be automatically taken care of when you purge scenes. Look up the ‘purge’,‘remove’ and other commands for specifics.

And post code!!! :slight_smile:

-Mario

OK, give us some code to check out. It will really help us pinpoint the problem.

Without code, I can guess that the problem you have is that you’re not inserting your button into the scene’s ‘group’. If you insert it into the scene’s group, then the button will be cleaned up (along with the event listener too!) automagically when you do a “purgeScene”.

Here’s a snippet of my code to switch scenes:

[lua]

function scene:createScene( event )
     – This is the display group that all your stuff
     – should be in for this particular scene
     local group = self.view
     myButton = display.newImageRect(group, “graphics/background.png”, _W, _H )
     
     – The event listener function for our ‘myButton’ graphic!
     function DoStuff:tap(e)
          – First purge our current scene…
          storyboard.purgeScene(storyboard.getCurrentSceneName())
          – Now go to our next scene
          storyboard.gotoScene( “scr_MyOtherScene”, { effect=“fade”, time = 250} )
     end
     – Attach the Event listener function “DoStuff” to the “myButton” grpahic
     myButton:addEventListener(“tap”,DoStuff)
end

[/lua]

Storyboard can be a tricky beast. Don’t get discouraged, keep hitting us up for help and we’ll be there for you. Just remember, always insert any of your scene specific graphics into ‘group’ and it should be automatically taken care of when you purge scenes. Look up the ‘purge’,‘remove’ and other commands for specifics.

And post code!!! :slight_smile:

-Mario