AnimatedSprite Module
Functions for creating, updating, and drawing animated sprites.
The update and draw functions are aggressively inlined and designed for zero allocations during the game loop.
Functions and values
| Function or value |
Description
|
Full Usage:
create sheet animationName
Parameters:
SpriteSheet
-
The sprite sheet containing animations.
animationName : string
-
Name of the animation to play initially.
Returns: AnimatedSprite
|
Create a new animated sprite starting on the specified animation.
|
Full Usage:
createWith sheet animationName color scale
Parameters:
SpriteSheet
animationName : string
color : Color
scale : float32
Returns: AnimatedSprite
|
Create with initial visual properties.
|
Full Usage:
currentSource sprite
Parameters:
AnimatedSprite
Returns: Rectangle
Modifiers: inline |
|
Full Usage:
draw position layer buffer sprite
Parameters:
Vector2
layer : int<MeasureProduct<RenderLayer, MeasureOne>>
buffer : RenderBuffer<RenderCmd2D>
sprite : AnimatedSprite
|
Draw the sprite at a position using the 2D render buffer. The sprite is drawn centered on the position with the sheet's origin.
|
Full Usage:
drawRect destRect layer buffer sprite
Parameters:
Rectangle
layer : int<MeasureProduct<RenderLayer, MeasureOne>>
buffer : RenderBuffer<RenderCmd2D>
sprite : AnimatedSprite
|
Draw the sprite at a specific destination rectangle (ignores scale/origin). Note: Rotation will occur around the top-left corner (Vector2.Zero) of the destination rectangle.
|
Full Usage:
drawWithDepth position depth layer buffer sprite
Parameters:
Vector2
depth : float32
layer : int<MeasureProduct<RenderLayer, MeasureOne>>
buffer : RenderBuffer<RenderCmd2D>
sprite : AnimatedSprite
|
Draw the sprite with a custom depth value.
|
|
|
Full Usage:
facingLeft sprite
Parameters:
AnimatedSprite
Returns: AnimatedSprite
Modifiers: inline |
|
Full Usage:
facingRight sprite
Parameters:
AnimatedSprite
Returns: AnimatedSprite
Modifiers: inline |
|
Full Usage:
flipX sprite
Parameters:
AnimatedSprite
Returns: AnimatedSprite
Modifiers: inline |
|
Full Usage:
flipY sprite
Parameters:
AnimatedSprite
Returns: AnimatedSprite
Modifiers: inline |
|
|
Is the current animation finished? (always false for looping animations)
|
Full Usage:
isPlaying animName sprite
Parameters:
string
sprite : AnimatedSprite
Returns: bool
|
Is currently playing the specified animation?
|
Full Usage:
play animationName sprite
Parameters:
string
sprite : AnimatedSprite
Returns: AnimatedSprite
|
Play an animation by name. Does string lookup only when actually changing.
|
Full Usage:
playByIndex animIndex sprite
Parameters:
int
sprite : AnimatedSprite
Returns: AnimatedSprite
|
Play by animation index (zero string allocation). For maximum performance, resolve animation names to indices once at load time, then use this function during gameplay.
|
Full Usage:
playIfNot animationName sprite
Parameters:
string
sprite : AnimatedSprite
Returns: AnimatedSprite
|
Play animation only if not already playing it.
|
|
Force restart the current animation from the beginning.
|
Full Usage:
toSpriteEffects sprite
Parameters:
AnimatedSprite
Returns: SpriteEffects
Modifiers: inline |
Get the MonoGame SpriteEffects for the sprite's current flip state.
|
Full Usage:
update deltaSeconds sprite
Parameters:
float32
sprite : AnimatedSprite
Returns: AnimatedSprite
|
Advance the animation by delta time. This function is designed for zero allocations. Call it from your Elmish update function each frame.
|
Full Usage:
withColor color sprite
Parameters:
Color
sprite : AnimatedSprite
Returns: AnimatedSprite
Modifiers: inline |
|
Full Usage:
withRotation rotation sprite
Parameters:
float32
sprite : AnimatedSprite
Returns: AnimatedSprite
Modifiers: inline |
|
Full Usage:
withScale scale sprite
Parameters:
float32
sprite : AnimatedSprite
Returns: AnimatedSprite
Modifiers: inline |
Mibo