Class SpriteExtensions
A sprite represents a series frames in an atlas forming an animation.
public static class SpriteExtensions
- Inheritance
-
SpriteExtensions
Methods
Draw(Sprite, SpriteBatch, Vector2, Color, Vector2, float, float, 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 = 0, float depthLayer = 0, SpriteEffects spriteEffects = SpriteEffects.None)
Parameters
sprite
SpriteThe sprite
spriteBatch
SpriteBatchThe sprite batch used to draw the sprite.
position
Vector2The position to which draw the sprite
color
ColorThe color to use to draw the sprite
scales
Vector2The scale factors to apply on the sprite
rotation
floatThe rotation to apply on the sprite
depthLayer
floatThe depth layer to which draw the sprite
spriteEffects
SpriteEffectsThe sprite effect to apply on the sprite
Remarks
This function must be called between the SpriteBatch.Begin(Stride.Graphics.SpriteSortMode,Stride.Graphics.Effect)
and SpriteBatch.End() calls of the provided spriteBatch
Exceptions
- ArgumentException
The provided frame index is not valid.
- ArgumentOutOfRangeException
The provided spriteBatch is null
Draw(Sprite, SpriteBatch, Vector2, float, float, 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 = 0, float depthLayer = 0, SpriteEffects spriteEffects = SpriteEffects.None)
Parameters
sprite
SpriteThe sprite
spriteBatch
SpriteBatchThe sprite batch used to draw the sprite.
position
Vector2The position to which draw the sprite
rotation
floatThe rotation to apply on the sprite
depthLayer
floatThe depth layer to which draw the sprite
spriteEffects
SpriteEffectsThe sprite effect to apply on the sprite
Remarks
This function must be called between the SpriteBatch.Begin(Stride.Graphics.SpriteSortMode,Stride.Graphics.Effect)
and SpriteBatch.End() calls of the provided spriteBatch
Exceptions
- ArgumentException
The provided frame index is not valid.
- 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
sprite
SpriteThe sprite
spriteBatch
Sprite3DBatchThe sprite batch used to draw the sprite.
worldMatrix
MatrixThe world matrix of the sprite
color
Color4The color to apply on the sprite
Remarks
This function must be called between the SpriteBatch.Begin(Stride.Graphics.SpriteSortMode,Stride.Graphics.Effect)
and SpriteBatch.End() calls of the provided spriteBatch
Exceptions
- ArgumentException
The provided frame index is not valid.
- ArgumentOutOfRangeException
The provided spriteBatch is null