Table of Contents

Class SpriteExtensions

Namespace
Stride.Graphics
Assembly
Stride.Graphics.dll

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 Sprite

The sprite

spriteBatch SpriteBatch

The sprite batch used to draw the sprite.

position Vector2

The position to which draw the sprite

color Color

The color to use to draw the sprite

scales Vector2

The scale factors to apply on the sprite

rotation float

The rotation to apply on the sprite

depthLayer float

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 Begin(GraphicsContext, SpriteSortMode, EffectInstance) 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 Sprite

The sprite

spriteBatch SpriteBatch

The sprite batch used to draw the sprite.

position Vector2

The position to which draw the sprite

rotation float

The rotation to apply on the sprite

depthLayer float

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 Begin(GraphicsContext, SpriteSortMode, EffectInstance) 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 Sprite

The sprite

spriteBatch Sprite3DBatch

The sprite batch used to draw the sprite.

worldMatrix Matrix

The world matrix of the sprite

color Color4

The color to apply on the sprite

Remarks

This function must be called between the Begin(GraphicsContext, SpriteSortMode, EffectInstance) and SpriteBatch.End() calls of the provided spriteBatch

Exceptions

ArgumentException

The provided frame index is not valid.

ArgumentOutOfRangeException

The provided spriteBatch is null