Skip to content

Class "Sprite"⚓︎

Constructors⚓︎

Sprite ()⚓︎

Sprite Sprite ( )⚓︎


Functions⚓︎

Get·Default·Animation ()⚓︎

string GetDefaultAnimation ( )⚓︎

This function returns the name of the "Default" animation of a given sprite based on its .anm2 file.

Info

This function seems to be the same as GetDefaultAnimationName().

Example Code

This code print the default animation name "WalkDown" of the player sprite.

1
2
3
local player = Isaac.GetPlayer(0)
local sprite = player:GetSprite()
print(sprite:GetDefaultAnimation()) -- this prints "WalkDown"

Get·Default·Animation·Name ()⚓︎

string GetDefaultAnimationName ( )⚓︎

This function returns the name of the "Default" animation of a given sprite based on its .anm2 file.

Info

This function seems to be the same as GetDefaultAnimation().

Example Code

This code print the default animation name "WalkDown" of the player sprite.

1
2
3
local player = Isaac.GetPlayer(0)
local sprite = player:GetSprite()
print(sprite:GetDefaultAnimationName()) -- this prints "WalkDown"

Get·Filename ()⚓︎

string GetFilename ( )⚓︎

This function returns the path to the .anm2 file used by the sprite.

Info

This function seems to be the same as GetDefaultAnimation().

Example Code

This code print the .anm2 path of the player sprite.

1
2
3
local player = Isaac.GetPlayer(0)
local sprite = player:GetSprite()
print(sprite:GetFilename()) -- this prints "gfx/001.000_Player.anm2"

Get·Frame ()⚓︎

int GetFrame ( )⚓︎

Returns the currently rendered Frame of the given Sprite.


Get·Layer·Count ()⚓︎

int GetLayerCount ( )⚓︎

Returns the number of layers of the .anm2 file of the sprite. All Animations use the same amount of Layers.


Get·Overlay·Frame ()⚓︎

int GetOverlayFrame ( )⚓︎

Returns the currently rendered Frame of the Overlay of the given Sprite. It acts independent from the normal Frame count.


Get·Texel ()⚓︎

Color GetTexel ( Vector SamplePos, Vector RenderPos, float AlphaThreshold )⚓︎


Is·Event·Triggered ()⚓︎

boolean IsEventTriggered ( string EventName )⚓︎


Is·Finished ()⚓︎

boolean IsFinished ( string AnimationName )⚓︎


Is·Loaded ()⚓︎

boolean IsLoaded ( )⚓︎


Is·Overlay·Finished ()⚓︎

boolean IsOverlayFinished ( string AnimationName )⚓︎


Is·Overlay·Playing ()⚓︎

boolean IsOverlayPlaying ( string AnimationName )⚓︎


Is·Playing ()⚓︎

boolean IsPlaying ( string AnimationName )⚓︎


Load ()⚓︎

void Load ( string Filename, boolean LoadGraphics )⚓︎

Loads a given ".anm2" file. The filepath is relative to the "resources" folder. The boolean can be used to load the graphics (.png files) as well, without calling the LoadGraphics() function.

Example Code

This code creates a new sprite object, loads an .anm2 file and renders it on the screen.

1
2
3
local mySprite = Sprite()
mySprite:Load("gfx/myCoolAnimation.anm2", true)
mySprite:Render(Vector(75,75), Vector(0,0), Vector(0,0))

Load·Graphics ()⚓︎

void LoadGraphics ( )⚓︎

Loads and applies assosiated graphic-objects like ".png" files.

Example Code

This code creates a new sprite object and replaces the spritesheet of layer 0 of a sprite object with a different spritesheet.

1
2
3
4
local mySprite = Sprite()
mySprite:Load("gfx/myCoolAnimation.anm2", true)
mySprite:ReplaceSpritesheet(0, "gfx/my_new_spritesheet.png")
mySprite:LoadGraphics()

Play ()⚓︎

void Play ( string AnimationName, boolean Force )⚓︎


Play·Overlay ()⚓︎

void PlayOverlay ( string AnimationName, boolean Force )⚓︎


Play·Random ()⚓︎

void PlayRandom ( int Seed )⚓︎


Reload ()⚓︎

void Reload ( )⚓︎


Remove·Overlay ()⚓︎

void RemoveOverlay ( )⚓︎


Render ()⚓︎

void Render ( Vector Pos, Vector TopLeftClamp, Vector BottomRightClamp )⚓︎


Render·Layer ()⚓︎

void RenderLayer ( int LayerId, Vector Pos )⚓︎


Replace·Spritesheet ()⚓︎

void ReplaceSpritesheet ( int LayerId, string PngFilename )⚓︎

Changes the ".png" file assosiated to a specific layer of a sprite.

Notes

The effect is only applied after calling the LoadGraphics() function afterwards.

Example Code

This code creates a new sprite object and replaces the spritesheet of layer 0 of a sprite object with a different spritesheet.

1
2
3
4
local mySprite = Sprite()
mySprite:Load("gfx/myCoolAnimation.anm2", true)
mySprite:ReplaceSpritesheet(0, "gfx/my_new_spritesheet.png")
mySprite:LoadGraphics()

Reset ()⚓︎

void Reset ( )⚓︎


Set·Animation ()⚓︎

boolean SetAnimation ( string AnimationName )⚓︎


Set·Frame ()⚓︎

void SetFrame ( string AnimationName, int FrameNum )⚓︎


Set·Last·Frame ()⚓︎

void SetLastFrame ( )⚓︎


Set·Layer·Frame ()⚓︎

void SetLayerFrame ( int LayerId, int FrameNum )⚓︎


Set·Overlay·Animation ()⚓︎

boolean SetOverlayAnimation ( string AnimationName )⚓︎


Set·Overlay·Frame ()⚓︎

void SetOverlayFrame ( string AnimationName, int FrameNum )⚓︎


Set·Overlay·Render·Priority ()⚓︎

void SetOverlayRenderPriority ( boolean RenderFirst )⚓︎


Stop ()⚓︎

void Stop ( )⚓︎


Update ()⚓︎

void Update ( )⚓︎


Was·Event·Triggered ()⚓︎

boolean WasEventTriggered ( string EventName )⚓︎


Variables⚓︎

FlipX⚓︎

boolean FlipX⚓︎


FlipY⚓︎

boolean FlipY⚓︎


Color⚓︎

Color Color⚓︎


Offset⚓︎

Vector Offset⚓︎


Playback·Speed⚓︎

float PlaybackSpeed⚓︎


Rotation⚓︎

float Rotation⚓︎


Scale⚓︎

Vector Scale⚓︎



Last update: June 9, 2021