Skip to content

Commit a9b003b

Browse files
Fix typos (#221)
1 parent 9ba97c2 commit a9b003b

File tree

1 file changed

+10
-9
lines changed
  • articles/tutorials/building_2d_games/21_customizing_gum_ui

1 file changed

+10
-9
lines changed

articles/tutorials/building_2d_games/21_customizing_gum_ui/index.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ title: "Chapter 21: Customizing Gum UI"
33
description: "Learn how to create custom UI components with animations and visual styling in Gum."
44
---
55

6-
In the [previous chapter](../20_implementing_ui_with_gum/index.md), we implemented a functional UI system for our game using the Gum framework. While the UI is now fully operational, it uses Gum's default styling. This default styling is good for quickly iterating when building the UI, but it does not match the game's visuals. A well designed UI should not only be functional but also complement the game's overall visual style to create a cohesive experience.
6+
In the [previous chapter](../20_implementing_ui_with_gum/index.md), we implemented a functional UI system for our game using the Gum framework. While the UI is now fully operational, it uses Gum's default styling. This default styling is good for quickly iterating when building the UI, but it does not match the game's visuals. A well-designed UI should not only be functional but also complement the game's overall visual style to create a cohesive experience.
77

8-
In this chapter you will:
8+
In this chapter, you will:
99

1010
- Learn about Gum's visual customization system and component hierarchy.
1111
- Understand how animation chains and visual states work in Gum.
@@ -160,7 +160,7 @@ Next, add this font file to your content project using the MGCB Editor:
160160
| **Figure 21-2: The MGCB Editor with the 04b_30.fnt added to the fonts folder and the Build property set to Copy** |
161161

162162
> [!NOTE]
163-
> When the *.fnt* font file was generated using the [AngelCode Bitmap Font Generator](https://www.angelcode.com/products/bmfont/), the graphics from the *.png* file that it produces was copied over into our existing texture atlas. By doing this, it allows Gum to render the visuals for elements and the text from the same atlas, reducing texture swapping.
163+
> When the *.fnt* font file was generated using the [AngelCode Bitmap Font Generator](https://www.angelcode.com/products/bmfont/), the graphics from the *.png* file that it produces were copied over into our existing texture atlas. By doing this, it allows Gum to render the visuals for elements and the text from the same atlas, reducing texture swapping.
164164
>
165165
> The font file references our existing texture atlas using a relative path that points to the atlas image.
166166
>
@@ -184,9 +184,9 @@ Now that we have all our resources prepared, we can create custom versions of th
184184

185185
Our first custom component is an `AnimatedButton` that inherits from Gum's base `Button` class. This button uses the game's existing texture atlas for its visual appearance and animates when focused.
186186

187-
By default all Gum components provide a Visual property which can be cast to a type specific to the particular control. By convention the visual type is named the same as the component with the word `Visual` appened. For example, we will be casting the AnimatedButton's Visual property to `ButtonVisual` to access button-specific properties.
187+
By default, all Gum components provide a Visual property which can be cast to a type specific to the particular control. By convention, the visual type is named the same as the component with the word `Visual` appended. For example, we will be casting the AnimatedButton's Visual property to `ButtonVisual` to access button-specific properties.
188188

189-
This new `AnimatedButton` class casts the Visual property to `ButtonVisual` and modifies the button-specific properties such as background and text.
189+
This new `AnimatedButton` class casts the Visual property to `ButtonVisual` and modifies the button-specific properties, such as background and text.
190190

191191
First, in the *DungeonSlime* project (your main game project), create a new folder named `UI` to store our custom UI components. Next, in that `UI` folder, create a new file called `AnimatedButton.cs` and add the following code to it:
192192

@@ -196,7 +196,7 @@ Next, we will examine the key aspects of this new `AnimatedButton` implementatio
196196

197197
#### ButtonVisual
198198

199-
As mentioned earlier, we first access the `Visual` object and cast it to a `ButtonVisual`. Doing so gives us access to button-specific properties including individual elements (such as the text and background visuals) as well as the states that are applied when the button is hovered or pressed.
199+
As mentioned earlier, we first access the `Visual` object and cast it to a `ButtonVisual`. Doing so gives us access to button-specific properties, including individual elements (such as the text and background visuals) as well as the states that are applied when the button is hovered or pressed.
200200

201201
We can modify the Visual to give it the appropriate size.
202202

@@ -206,15 +206,15 @@ The `WidthUnits` property set to `RelativeToChildren` means the container autom
206206

207207
#### Nine-slice Background
208208

209-
`ButtonVisual` provides a `Background` which we can modify. This is of type `NineSliceRuntime` which is a special graphic that can be stretch while preserving its corners and edges:
209+
`ButtonVisual` provides a `Background` which we can modify. This is of type `NineSliceRuntime`, which is a special graphic that can be stretched while preserving its corners and edges:
210210

211211
[!code-csharp[](./snippets/animatedbutton.cs?start=39&end=42)]
212212

213213
The `TextureAddress` property is set to `Custom` so we can specify exactly which portion of the atlas texture to use, while `Dock(Dock.Fill)` ensure the background fills the entire button area. The portion of the atlas is assigned using AnimationChains, which are discussed later in this tutorial.
214214

215215
#### Text
216216

217-
`ButtonVisual` also provides a customizable `Text` property. In this case we assign the font, color, and size.
217+
`ButtonVisual` also provides a customizable `Text` property. In this case, we assign the font, color, and size.
218218

219219
[!code-csharp[](./snippets/animatedbutton.cs?start=45&end=55)]
220220

@@ -231,7 +231,7 @@ Each animation frame specifies the coordinates within our texture atlas to displ
231231

232232
#### States and Categories
233233

234-
In Gum, each control type has a specific category name that identifies its state collection. `ButtonVisual` provides access to ready-made states and catgories which we can modify. Before we speicfy how a state should modify the button's appearance, we clear out all existing functionality so that we can fully control the states:
234+
In Gum, each control type has a specific category name that identifies its state collection. `ButtonVisual` provides access to ready-made states and categories which we can modify. Before we specify how a state should modify the button's appearance, we clear out all existing functionality so that we can fully control the states:
235235

236236
[!code-csharp[](./snippets/animatedbutton.cs?start=104&end=104)]
237237

@@ -446,3 +446,4 @@ The principles you have learned in this chapter extend beyond the specific compo
446446
- Makes it easier to create controls that work with mouse, keyboard, and gamepad input.
447447

448448
:::
449+

0 commit comments

Comments
 (0)