Scoring Hud
Last updated
Last updated
This tutorial covers creating a HUD object which displays the scores of each player.
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:
Select the Quick Actions tab
Click the Add Entity button
Enter the name ScoreHud
Click OK
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:
Select ScoreHud
Select the Quick Actions tab
Click the Add Object to ScoreHud
Select Text as the type
Enter the name Team1Score
Click OK
Repeat the steps above to create another Text object called Team2Score
Repeat the steps above to create another Text object called Team1ScoreLabel
Repeat the steps above to create another Text object called Team2ScoreLabel
You should now have 4 Text objects:
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: Team1Score
DisplayText = "99"
X = -150
Y = 270
Team2Score
DisplayText = "99"
X = 180
Y = 270
Team1ScoreLabel
DisplayText = "Team 1:"
X = -205
Y = 270
Team2ScoreLabel
DisplayText = "Team 2:"
X = 124
Y = 270
To add the ScoreHud to the GameScreen:
Select the ScoreHud
Select the Quick Actions tab
Click the Add ScoreHud Instance to GameScreen button
You should now see everything showing up correctly in your game
Now we have a score HUD that shows up when the game plays, but it doesn't react to scored goals. The next tutorial adds the necessary logic to have it react to scored goals.