Type Function
Library composer.*
Return value none
Revision Release 2024.3703
Keywords composer, scene, remove, removeScene
See also composer.removeHidden()


This function removes the specified scene (or optionally recycles it). A destroy event is first dispatched to the scene.

To recycle the scene instead of removing it entirely, you may set the shouldRecycle parameter to true — this means that the scene's self.view display group will be removed, but its scene object will remain in memory. This may improve loading time if you access the scene frequently. If shouldRecycle is omitted or set to false (default), the scene will be removed entirely, including its scene object.


composer.removeScene( sceneName [, shouldRecycle] )
sceneName (required)

String. The name of the scene to recycle or remove. For instance, if you want to recycle or remove scene1.lua, pass "scene1" as this parameter.

shouldRecycle (optional)

Boolean. If the scene should be recycled, but not removed entirely, set this parameter to true. Default is false.


-- Completely remove the scene, including its scene object
composer.removeScene( "scene1" )
-- Recycle the scene (its view is removed but its scene object remains in memory)
composer.removeScene( "scene1", true )