Adding Components to Layers
Last updated
Last updated
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.
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
The first step is to add the entire Gum screen as an object in 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
Now the Screen can be added to the Glue Layer:
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
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.
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
Now the entire GumScreenInstance (that is the entire MainScreen from Gum) will be drawn on LayerInstance.