03. Creating a Screen

Introduction

Screens and Entities are two common FlatRedBall concepts. 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

  2. Uncheck Add Map LayeredTileMap option – Beefball doesn’t use Tiled maps
  3. Accept the other 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.

PlayerBallList in GameScreen

By default, your GameScreen now has a PlayerBallList – this is a list which will contain all PlayerBall instances in your GameScreen.

If you unchecked the Add Lists for Entities option, or if you would like to know how to create lists manually, the following steps will help.

  1. Select 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 the editor or through game code. The editor provides a number of ways to add an entity:

  • Drag+drop an entity on a screen to add an instance…
  • … or add 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…

  • … or add 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

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 the FlatRedBall Editor or Visual Studio.

  • To run the game through the editor, 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 ->