SpriteExtensions Class
Namespace: Stride.GraphicsAssembly: Stride.Graphics.dll
A sprite represents a series frames in an atlas forming an animation.
public static class SpriteExtensions
| Name | Description | |
|---|---|---|
| Methods | ||
| Draw(Sprite, SpriteBatch, Vector2, Color, Vector2, Single, Single, SpriteEffects) | Draw a sprite using a sprite batch. |
|
| Draw(Sprite, SpriteBatch, Vector2, Single, Single, SpriteEffects) | Draw a sprite using a sprite batch and with white color and scale of 1. |
|
| Draw3D(Sprite, Sprite3DBatch, ref Matrix, ref Color4) | Draw a sprite in the 3D world using the provided 3D sprite batch, world matrix and color. |
|
Methods
Draw(Sprite, SpriteBatch, Vector2, Color, Vector2, Single, Single, SpriteEffects)
Draw a sprite using a sprite batch.
public static void Draw(this Sprite sprite, SpriteBatch spriteBatch, Vector2 position, Color color, Vector2 scales, float rotation = 0F, float depthLayer = 0F, SpriteEffects spriteEffects = SpriteEffects.None)
Parameters
| Type | Name | Description |
|---|---|---|
| Sprite | sprite | The sprite |
| SpriteBatch | spriteBatch | The sprite batch used to draw the sprite. |
| Vector2 | position | The position to which draw the sprite |
| Color | color | The color to use to draw the sprite |
| Vector2 | scales | The scale factors to apply on the sprite |
| System.Single | rotation | The rotation to apply on the sprite |
| System.Single | depthLayer | The depth layer to which draw the sprite |
| SpriteEffects | spriteEffects | The sprite effect to apply on the sprite |
Remarks
This function must be called between the spriteBatch
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | The provided frame index is not valid. |
| System.ArgumentOutOfRangeException | The provided spriteBatch is null |
Draw(Sprite, SpriteBatch, Vector2, Single, Single, SpriteEffects)
Draw a sprite using a sprite batch and with white color and scale of 1.
public static void Draw(this Sprite sprite, SpriteBatch spriteBatch, Vector2 position, float rotation = 0F, float depthLayer = 0F, SpriteEffects spriteEffects = SpriteEffects.None)
Parameters
| Type | Name | Description |
|---|---|---|
| Sprite | sprite | The sprite |
| SpriteBatch | spriteBatch | The sprite batch used to draw the sprite. |
| Vector2 | position | The position to which draw the sprite |
| System.Single | rotation | The rotation to apply on the sprite |
| System.Single | depthLayer | The depth layer to which draw the sprite |
| SpriteEffects | spriteEffects | The sprite effect to apply on the sprite |
Remarks
This function must be called between the spriteBatch
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | The provided frame index is not valid. |
| System.ArgumentOutOfRangeException | The provided spriteBatch is null |
Draw3D(Sprite, Sprite3DBatch, ref Matrix, ref Color4)
Draw a sprite in the 3D world using the provided 3D sprite batch, world matrix and color.
public static void Draw3D(this Sprite sprite, Sprite3DBatch spriteBatch, ref Matrix worldMatrix, ref Color4 color)
Parameters
| Type | Name | Description |
|---|---|---|
| Sprite | sprite | The sprite |
| Sprite3DBatch | spriteBatch | The sprite batch used to draw the sprite. |
| Matrix | worldMatrix | The world matrix of the sprite |
| Color4 | color | The color to apply on the sprite |
Remarks
This function must be called between the spriteBatch
Exceptions
| Type | Condition |
|---|---|
| System.ArgumentException | The provided frame index is not valid. |
| System.ArgumentOutOfRangeException | The provided spriteBatch is null |