The RemoveLayer function removes the current Layer from the SpritManager. This function can be used to remove Layers once they are no longer needed (such as Layers created in custom code), or to move Layers between different Cameras.
The following code shows how to create and destroy a Layer in custom code. This code is similar to code created by Glue in generated code when a Layer is added to a Screen:
Layers can be contained in Cameras and in the SpriteManager (not associated with any Camera). For example the following code would remove a Layer from the SpriteManager and move it to a Camera:
Note that the above code will result in an exception if the Layer is not manually removed from the Camera when the Screen is destroyed.