03. Creating a Screen

Introduction

Screens and Entities are two common concepts in Glue. A Screen represents a container for game content and other Entities. Screens define the flow of your game. Often game developers will create many screens up-front to help them think through a game’s structure.

  • Game play Screen (like the playing Screen in Pong). This is usually called “GameScreen”
  • Splash Screen (like a FlatRedBall logo displaying splash Screen)
  • Main menu Screen

Creating a Screen

As you work with Screens you will find that they are very similar to Entities. To create a Screen:

  1. Click on the Screens folder and select the Add Screen quick action, or right-click on the Screens folder and select Add Screen

    or

  2. Accept the default name GameScreen and click OK. Glue provides extra functionality if you name the screen for your game logic “GameScreen”

You should now have a Screen in game called GameScreen.

Adding an Entity Instance to GameScreen

Once you have at least one Screen in your game (GameScreen), you can add Entity instances to that Screen. Entities can be added through Glue or through game code. Glue provides a number of ways to add an entity:

  • Glue supports drag+dropping an entity on a Screen to add an instance.
  • Glue also supports adding an instance to the GameScreen by selecting PlayerBall and clicking the Add PlayerBall Instance to GameScreen quick action. Note that this option will only exist if you have a Screen called GameScreen.

  • Glue also supports adding an object to a screen by right-clicking on the GameScreen’s Objects folder:
    • Right-click on your GameScreen’s Objects folder
    • Select Add Object
    • Select Entity as the object type
    • Select PlayerBall as the type. The name will automatically be changed to PlayerBallInstance
    • Click OK

NewPlayerBallInstance.png

Running your Game

Now that you have a PlayerBall instance in your GameScreen, you can run the game to see it. You can run the game through either Glue or Visual Studio.

  • To run the game through Glue, click the Play button in the toobar at the top

  • To run the game through Visual Studio, click the Visual Studio icon to open the game in Visual Studio and run it like any other desktop project

Conclusion

To recap we now have an Entity called PlayerBall which has a Circle. We’ve also created a GameScreen which contains an instance of our PlayerBall. If we run our game, it will show a white circle (our PlayerBall instance).

We’re now ready to start adding some code to our project. The next tutorial will cover controlling your Entity’s movement.

<- Creating an EntityControlling an Entity ->