Godot Engine Game Development Projects
上QQ阅读APP看书,第一时间看更新

Message label

Add a Label node to the scene and change its name to MessageLabel. This label will display the game's title, as well as Game Over when the game ends. This label should be centered on the game screen. You could drag it with the mouse, but to place UI elements precisely, you should use the Anchor properties.

Select View | Show Helpers to display pins that will help you see the anchor positions, then click on the Layout menu and select HCenter Wide:

The MessageLabel now spans the width of the screen and is centered vertically. The Text property in the Inspector sets what text the label displays. Set it to Coin Dash! and set Align and Valign to Center.

The default font for Label nodes is very small, so the next step is to assign a custom font. Scroll down to the Custom Fonts section in the Inspector and select New DynamicFont, as shown in the following screenshot:

Now, click on DynamicFont and you can adjust the font settings. From the FileSystem dock, drag the Kenney Bold.ttf font and drop it in the Font Data property. Set Size to 48, as shown in the following screenshot: