Skip to content

Commit 1682939

Browse files
authored
Update tutorial for drawing masked sprite backgrounds (#177)
* Update tutorial for drawing masked sprite backgrounds * Add note on revising the How to draw a Sprite topic * Add additional link to How to Tint a Sprite guide * Add relative links instead of hardcoded ones
1 parent f270a3f commit 1682939

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

articles/getting_to_know/howto/graphics/HowTo_Draw_A_Sprite.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ The following texture will be used to render to the screen.
2121
Save it to your content project and name it "**Character**" (this name will used to reference it in the project).
2222

2323
> [!NOTE]
24-
> The tutorial assumes you have already [created a new MonoGame project](https://docs.monogame.net/articles/getting_started/index.html#2-creating-a-new-project) using one of the standard templates.
24+
> The tutorial assumes you have already [created a new MonoGame project](../../../getting_started/index.md#setting-up-and-creating-your-first-monogame-project) using one of the standard templates.
2525
2626
## To draw a sprite on screen
2727

@@ -54,7 +54,7 @@ Save it to your content project and name it "**Character**" (this name will used
5454
5. Call [SpriteBatch.Draw](xref:Microsoft.Xna.Framework.Graphics.SpriteBatch#Microsoft_Xna_Framework_Graphics_SpriteBatch_Draw_Microsoft_Xna_Framework_Graphics_Texture2D_Microsoft_Xna_Framework_Vector2_Microsoft_Xna_Framework_Color_) on your [SpriteBatch](xref:Microsoft.Xna.Framework.Graphics.SpriteBatch) object, passing the texture to draw, the screen position, and the color to apply.
5555

5656
> [!TIP]
57-
> [Color.White](xref:Microsoft.Xna.Framework.Color) is used to draw the texture without any color effects.
57+
> [Color.White](xref:Microsoft.Xna.Framework.Color) is used to draw the texture without any color effects. For a deeper explanation of how sprite tinting works, check out the [How to Tint a Sprite](HowTo_Tint_Sprite.md) guide.
5858

5959
6. When all the sprites have been drawn, call [SpriteBatch.End](xref:Microsoft.Xna.Framework.Graphics.SpriteBatch#Microsoft_Xna_Framework_Graphics_SpriteBatch_End) on your [SpriteBatch](xref:Microsoft.Xna.Framework.Graphics.SpriteBatch) object.
6060

@@ -130,3 +130,4 @@ See [How to detect input](../input/index.md) for more information on working wit
130130
- [Texture2D](xref:Microsoft.Xna.Framework.Graphics.Texture2D)
131131

132132
(Character by `upklyak` from [FreePik](https://www.freepik.com/free-vector/cartoon-alien-character-animation-sprite-sheet_33397951.htm))
133+

articles/getting_to_know/howto/graphics/HowTo_Draw_Sprite_Background.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ The example assumes the texture you are loading contains multiple images, one fo
2121

2222
Save the textures to your content project and name it "**AnimatedCharacter**" (this name will used to reference it in the project).
2323

24+
> [!NOTE]
25+
> The tutorial assumes you have already viewed the [How to draw a Sprite](HowTo_Draw_A_Sprite.md) topic.
26+
2427
> [!IMPORTANT]
2528
> The foreground sprite in this example must include masking information, e.g. a PNG or DDS file that supports transparency / an alpha channel.
2629
@@ -70,7 +73,7 @@ Save the textures to your content project and name it "**AnimatedCharacter**" (t
7073
GraphicsDevice.Clear(Color.CornflowerBlue);
7174

7275
_spriteBatch.Begin(blendState: BlendState.Opaque);
73-
_spriteBatch.Draw (starTexture);
76+
_spriteBatch.Draw(starTexture, Vector2.Zero, Color.White);
7477
_spriteBatch.End();
7578
}
7679
```
@@ -88,7 +91,7 @@ Save the textures to your content project and name it "**AnimatedCharacter**" (t
8891
public override void Draw (GameTime game)
8992
{
9093
_spriteBatch.Begin(blendState: BlendState.Opaque);
91-
_spriteBatch.Draw (starTexture);
94+
_spriteBatch.Draw(starTexture, Vector2.Zero, Color.White);
9295
_spriteBatch.End();
9396

9497
_spriteBatch.Begin(blendState: BlendState.AlphaBlend);
@@ -117,3 +120,5 @@ Try using this technique on top of the [How To Make A Scrolling Background](HowT
117120
- [SpriteBatch](xref:Microsoft.Xna.Framework.Graphics.SpriteBatch)
118121
- [SpriteBatch.Draw](xref:Microsoft.Xna.Framework.Graphics.SpriteBatch#Microsoft_Xna_Framework_Graphics_SpriteBatch_Draw_Microsoft_Xna_Framework_Graphics_Texture2D_Microsoft_Xna_Framework_Vector2_Microsoft_Xna_Framework_Color_)
119122
- [Texture2D](xref:Microsoft.Xna.Framework.Graphics.Texture2D)
123+
124+

0 commit comments

Comments
 (0)