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
spriteSpriteThe sprite
spriteBatchSpriteBatchThe sprite batch used to draw the sprite.
positionVector2The position to which draw the sprite
colorColorThe color to use to draw the sprite
scalesVector2The scale factors to apply on the sprite
rotationfloatThe rotation to apply on the sprite
depthLayerfloatThe depth layer to which draw the sprite
spriteEffectsSpriteEffectsThe 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
spriteSpriteThe sprite
spriteBatchSpriteBatchThe sprite batch used to draw the sprite.
positionVector2The position to which draw the sprite
rotationfloatThe rotation to apply on the sprite
depthLayerfloatThe depth layer to which draw the sprite
spriteEffectsSpriteEffectsThe 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
spriteSpriteThe sprite
spriteBatchSprite3DBatchThe sprite batch used to draw the sprite.
worldMatrixMatrixThe world matrix of the sprite
colorColor4The 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