Adding Components to Layers


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

  1. Right-click on Objects

  2. Select "Add Object"

  3. Select the "From File" option

  4. Select the MainScreen.gusx file

  5. Select "this" option (the first option in the drop-down

  6. Enter the name GumScreenInstance

  7. Click OK

  1. Right-click on Objects

  2. Select "Add Object"

  3. Make sure "FlatRedBall or Custom Type" is selected

  4. Select Layer

  5. Click OK

  6. 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:

  1. Open the project in Visual Studio

  2. Open GameScreen.cs

  3. Add the following code to CustomInitialize:

void CustomInitialize()
    GameScreenGum.MoveToFrbLayer(LayerInstance, LayerInstanceGum);

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:

  1. Verify that your Glue screen has a Gum screen.

  2. Right-click on the Objects folder

  3. Add a new Layer

  4. Right-click on the Objects folder

  5. Select "From File"

  6. Select the Gum screen (.gusx)

  7. Select the object within the Gum screen which you'd like to move to a new layer

  8. Drag+drop the object onto the Glue layer

Last updated