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 defaults by clicking OK.

Notice that Glue suggests the name GameScreen for your screen. Recommended practice is to always have the screen where your game takes place called GameScreen.

Adding PlayerBallList to GameScreen

Depending on which version of Glue you are running, you may need to manually create a PlayerBallList in the new GameScreen. Recommended practice is to place any collidable entity in a list.

Before adding the list, check if Glue has already added the PlayerList for you – newer versions of Glue will do this automatically. If it is already added, you will see the PlayerBallList under the GameScreen Objects folder as shown in the following image:

If you do not see the PlayerBallList there, you can add it by:

  1. Selecting the PlayerBall entity
  2. Click the Quick Actions tab
  3. Click the Add PlayerBall List to GameScreen button

The PlayerBallList object will contain all of the PlayerBalls we plan on adding later. Our game is a two-player game, so it will eventually contain two PlayerBall instances. The PlayerBallList object will be used to define collision relationships in a later tutorial. Collision relationships define which objects can collide with each other (such as players vs the walls) and what to do when they collide (such as performing bounce physics).

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

Moving your PlayerBall to the PlayerBallList

Depending on the version of Glue that you are running, your PlayerBall may not be automatically added to the PlayerBallList. If not, you can drag+drop the PlayerBall object to the PlayerBallList as shown in the following animation:

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 ->