How do i completly remove a scene

I have a game.lua and when i press a button it removes the whole game.lua like everything thats in that scene it just deletes it and goes to menu.lua and on menu .lua when i press play it goes to game .lua again and over and over again…

note that i do have eventlisteners and physics and timers and other stuff in game.lua… thanks

Anyone? I’m pretty stuck …

At the expense of repeating myself in every tutorial, guide and forum post on this topic.

Create things in scene:create()

You do have to call physics.start() and physics.pause() so you can add bodies, but you don’t want physics running yet.

In scene:show()'s “did” phase, start physics again, start any timers, transitions etc. and add any “Runtime” (not object) listeners.  You need to store references to each timer and transition that may need stopped later.  This also goes for background audio for the scene as well.

In scene:hide() undo everything you started.  Call physics.stop(), for every timer or transition’s handle you started, stop them by calling their cancel functions (i.e. timer.cancel()).  Stop any audio that’s playing.  Remove any Runtime listeners (i.e. Runtime:removeEventListener( “enterFrame”, whateverFunctionUseUsedEarlier ) ).  This is your responsibility to do.

Any objects that have listeners will go away when the object dies.  Then to kill old objects make sure to call composer.removeScene(“scenename”) of the scene you’re going to and it will destroy your objects.

Now before you can do a lot of this, you would have to have properly created the objects so they are visible to these scene event functions.  We just published a tutorial today on Scope that I highly recommend that you read:

https://coronalabs.com/blog/2015/06/16/tutorial-scope-for-beginners/

Rob

Solved

Anyone? I’m pretty stuck …

At the expense of repeating myself in every tutorial, guide and forum post on this topic.

Create things in scene:create()

You do have to call physics.start() and physics.pause() so you can add bodies, but you don’t want physics running yet.

In scene:show()'s “did” phase, start physics again, start any timers, transitions etc. and add any “Runtime” (not object) listeners.  You need to store references to each timer and transition that may need stopped later.  This also goes for background audio for the scene as well.

In scene:hide() undo everything you started.  Call physics.stop(), for every timer or transition’s handle you started, stop them by calling their cancel functions (i.e. timer.cancel()).  Stop any audio that’s playing.  Remove any Runtime listeners (i.e. Runtime:removeEventListener( “enterFrame”, whateverFunctionUseUsedEarlier ) ).  This is your responsibility to do.

Any objects that have listeners will go away when the object dies.  Then to kill old objects make sure to call composer.removeScene(“scenename”) of the scene you’re going to and it will destroy your objects.

Now before you can do a lot of this, you would have to have properly created the objects so they are visible to these scene event functions.  We just published a tutorial today on Scope that I highly recommend that you read:

https://coronalabs.com/blog/2015/06/16/tutorial-scope-for-beginners/

Rob

Solved