Adding Components to Layers
Introduction
Gum Screens and Components can be added to Layers in Glue. This page discusses some common scenarios for layering Gum objects in Glue. For information on moving Gum objects to layers in code, see the MoveToFrbLayer page.
Adding an entire Screen to a Layer in Glue
Entire Gum Screens can be added to a Glue Layer. The following steps assume:
A Glue Screen called GameScreen
A Gum screen called MainScreen
The Gum screen added as a file under the Glue screen
Right-click on Objects
Select "Add Object"
Select the "From File" option
Select the MainScreen.gusx file
Select "this" option (the first option in the drop-down
Enter the name GumScreenInstance
Click OK
Right-click on Objects
Select "Add Object"
Make sure "FlatRedBall or Custom Type" is selected
Select Layer
Click OK
Drag+drop the GumScreenInstance onto the newly-created Layer
Adding an Entire Gum Screen to a Layer in Code
Gum screens can also be added to Glue Layers in code. For this example we'll assume your project already has:
A Glue screen (GameScreen)
A Gum screen in the Glue screen (GameScreenGum)
A Layer (LayerInstance)
To add the Gum screen to the Layer in code:
Open the project in Visual Studio
Open GameScreen.cs
Add the following code to CustomInitialize:
Note that the call requires two layers: LayerInstance and LayerInstanceGum. This is required because the GameScreenGum is a Gum object, so ultimately it must exist on a Gum layer. However, Glue simplifies this process by creating a Gum layer for every FlatRedBall layer automatically, so you do not have to worry about creating the Gum layer yourself if you added a Layer through Glue.
Splitting objects on multiple Layers
Individual objects within a Gum screen can be added to a Layer. To add an object to a layer:
Verify that your Glue screen has a Gum screen.
Right-click on the Objects folder
Add a new Layer
Right-click on the Objects folder
Select "From File"
Select the Gum screen (.gusx)
Select the object within the Gum screen which you'd like to move to a new layer
Drag+drop the object onto the Glue layer
Last updated