You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/getting_to_know/howto/graphics/HowTo_Animate_Sprite.md
+21-8Lines changed: 21 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,18 @@ requireMSLicense: true
8
8
9
9
In this example, you will draw a sprite to the screen and then animate the sprite using a custom sprite animation class.
10
10
11
+
### End result
12
+
13
+

14
+
15
+
> [!NOTE]
16
+
> Better animations can be done with better images and more frames, have a look at the [Platformer Sample](https://github.com/MonoGame/MonoGame.Samples/tree/3.8.1/Platformer2D) Provided by MonoGame for example.
17
+
11
18
## Requirements
12
19
13
20
The example assumes the texture you are loading contains multiple frames of the same size in a texture whose size is uniform (also known as a spritesheet), for example, the following spritesheet contains 8 Images of a character in different phases of motion, when player together it looks like it is animated.
Copy file name to clipboardExpand all lines: articles/getting_to_know/howto/graphics/HowTo_Draw_A_Sprite.md
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -8,11 +8,15 @@ requireMSLicense: true
8
8
9
9
In any game, drawing basic textures to the screen is essential knowledge, whether it is for menus and background images, to 2D game textures and characters. In this sample we will walk though the steps needed to load a texture and then render it on the screen.
10
10
11
+
### End result
12
+
13
+

14
+
11
15
## Requirements
12
16
13
17
The following texture will be used to render to the screen.
Save it to your content project and name it "**Character**" (this name will used to reference it in the project).
18
22
@@ -26,7 +30,7 @@ Save it to your content project and name it "**Character**" (this name will used
26
30
In this case, the example uses the **Content** member to load a texture from the MonoGame Framework Content Pipeline.
27
31
28
32
> [!IMPORTANT]
29
-
> The texture must be in the project, with the same name passed to [ContentManager.Load](xref:Microsoft.Xna.Framework.Content.ContentManager#Microsoft_Xna_Framework_Content_ContentManager_Load__1_System_String_).
33
+
> The texture must be in the project, with the same **Name** passed to [ContentManager.Load](xref:Microsoft.Xna.Framework.Content.ContentManager#Microsoft_Xna_Framework_Content_ContentManager_Load__1_System_String_). In this case the texture should be called "Character"!!
Copy file name to clipboardExpand all lines: articles/getting_to_know/howto/graphics/HowTo_Rotate_Sprite.md
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,10 @@ Rotating images and sprites is easy enough, but the main thing to keep in mind i
10
10
11
11
This guide walks you through calculating a new origin for images (the center in this case) and using that to determine to draw and rotate your sprite from.
12
12
13
+
### End result
14
+
15
+

16
+
13
17
## Drawing a Rotated Sprite
14
18
15
19
1. Follow the procedures of [Drawing a Sprite](HowTo_Draw_A_Sprite.md).
@@ -47,7 +51,9 @@ This guide walks you through calculating a new origin for images (the center in
47
51
The angle is specified in radians, and it can be greater than two times `π`, but does not need to be.
48
52
49
53
```csharp
54
+
// The angle at which to rotate and draw the sprite at
50
55
private float rotationAngle;
56
+
51
57
protectedoverridevoidUpdate(GameTimegameTime)
52
58
{
53
59
if (GamePad.GetState(PlayerIndex.One).Buttons.Back==ButtonState.Pressed||Keyboard.GetState().IsKeyDown(Keys.Escape))
@@ -57,6 +63,7 @@ This guide walks you through calculating a new origin for images (the center in
Copy file name to clipboardExpand all lines: articles/getting_to_know/howto/graphics/HowTo_Tint_Sprite.md
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,10 @@ requireMSLicense: true
8
8
9
9
Tinting sprites is an easy way to either animate a sprite (when it takes damage) or even to create different characters of different colors. It is quick and efficient to do and all you need is the color to tine with and a single change to your `SpriteBatch` draw call.
10
10
11
+
### End result
12
+
13
+

14
+
11
15
## Drawing a Tinted Sprite
12
16
13
17
1. Follow the procedures of [Drawing a Sprite](HowTo_Draw_A_Sprite.md).
@@ -16,7 +20,9 @@ Tinting sprites is an easy way to either animate a sprite (when it takes damage)
16
20
In this example, the position of the mouse determines the Red, Green, values to apply to the sprite, the blue is fixed for simplicity.
17
21
18
22
```csharp
23
+
// The color tint to apply to the sprite
19
24
protectedColortint;
25
+
20
26
protectedoverridevoidUpdate(GameTimegameTime)
21
27
{
22
28
if (GamePad.GetState(PlayerIndex.One).Buttons.Back==ButtonState.Pressed||Keyboard.GetState().IsKeyDown(Keys.Escape))
@@ -39,6 +45,7 @@ Tinting sprites is an easy way to either animate a sprite (when it takes damage)
39
45
40
46
// TODO: Add your drawing code here
41
47
_spriteBatch.Begin();
48
+
// Note the final argument in the Draw call is changed from Color.White to the new "tint" property
0 commit comments