Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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).

> [!NOTE]
> 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.
> 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.

## To draw a sprite on screen

Expand Down Expand Up @@ -54,7 +54,7 @@ Save it to your content project and name it "**Character**" (this name will used
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.

> [!TIP]
> [Color.White](xref:Microsoft.Xna.Framework.Color) is used to draw the texture without any color effects.
> [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.

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.

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ The example assumes the texture you are loading contains multiple images, one fo

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

> [!NOTE]
> The tutorial assumes you have already viewed the [How to draw a Sprite](HowTo_Draw_A_Sprite.md) topic.

> [!IMPORTANT]
> The foreground sprite in this example must include masking information, e.g. a PNG or DDS file that supports transparency / an alpha channel.

Expand Down Expand Up @@ -70,7 +73,7 @@ Save the textures to your content project and name it "**AnimatedCharacter**" (t
GraphicsDevice.Clear(Color.CornflowerBlue);

_spriteBatch.Begin(blendState: BlendState.Opaque);
_spriteBatch.Draw (starTexture);
_spriteBatch.Draw(starTexture, Vector2.Zero, Color.White);
_spriteBatch.End();
}
```
Expand All @@ -88,7 +91,7 @@ Save the textures to your content project and name it "**AnimatedCharacter**" (t
public override void Draw (GameTime game)
{
_spriteBatch.Begin(blendState: BlendState.Opaque);
_spriteBatch.Draw (starTexture);
_spriteBatch.Draw(starTexture, Vector2.Zero, Color.White);
_spriteBatch.End();

_spriteBatch.Begin(blendState: BlendState.AlphaBlend);
Expand Down Expand Up @@ -117,3 +120,5 @@ Try using this technique on top of the [How To Make A Scrolling Background](HowT
- [SpriteBatch](xref:Microsoft.Xna.Framework.Graphics.SpriteBatch)
- [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_)
- [Texture2D](xref:Microsoft.Xna.Framework.Graphics.Texture2D)