10. Scoring HUD

Introduction

This tutorial covers creating a HUD object which will display the scores of each player.

Creating a ScoreHud Entity

First we’ll create an Entity to store all of our scoring information. We could place all of our HUD objects directly in the Screen, but this approach can result in a large number of objects in the GameScreen, making it difficult to maintain. We’ll create a “Hud” entity to keep all HUD objects organized. To do this:

  1. Right-click on the Entities item in Glue
  2. Select “Add Entity”
  3. Enter the name “ScoreHud”
  4. Click OK

Creating the ScoreHud Text objects

For the ScoreHud we’ll define the Text objects in Glue (just like we defined the body of the Puck in Glue). To do this:

  1. Expand ScoreHud
  2. Right-click on Objects
  3. Select “Add Object”
  4. Select “FlatRedBall or Custom Type”
  5. Select “Text” as the type
  6. Enter the name “Team1Score”
  7. Click OK
  8. Repeat the steps above to create another Text object called Team2Score
  9. Repeat the steps above to create another Text object called Team1ScoreLabel
  10. Repeat the steps above to create another Text object called Team2ScoreLabel

You should now have 4 Text objects:
FourScoreTextsInHud.PNG

Now we’ll change the following variables on the Text objects in Glue. Select the following Text objects and set the variables as defined below:

Team1ScoreLabel

  • DisplayText = “Team 1:”
  • X = -205
  • Y = 270

Team2ScoreLabel

  • DisplayText = “Team 2:”
  • X = 124
  • Y = 270

Team1Score

  • DisplayText = “99”
  • X = -150
  • Y = 270

Team2Score

  • DisplayText = “99”
  • X = 180
  • Y = 270

The Text objects should be arranged as follows:

ArrangedTextObjectsBeefballHud.PNG

Adding a ScoreHud to your Screen

Now that we have a ScoreHud that is displaying Text you can click+drag from “ScoreHud” into your GameScreen to create an instance:

  1. Find your ScoreHud Entity
  2. Push the mouse button when over ScoreHud
  3. Drag the mouse down and release on “GameScreen”
  4. This will create an object in your GameScreen called “ScoreHudInstance”

You should now see everything showing up correctly in GlueView and in your game
HudAndGameInGlueView.png

Conclusion

Now we have a score HUD that shows up when the game plays, but it doesn’t react to scored goals. The next tutorial will add the necessary logic to have it react to scored goals.

<- Scoring and RestartingScoring HUD Logic ->