Sprites
Functions
Section titled “Functions”clearSprite()
Section titled “clearSprite()”clearSprite(
sprite, …layerIDs):void
Defined in: packages/isaacscript-common/src/functions/sprites.ts:26
Helper function to clear all layers or specific layers from a sprite without unloading the attached anm2 file.
This function is variadic, which means you can pass as many layer IDs as you want to clear. If no specific layers are passed, the function will clear every layer.
If you want to clear all of the layers of a sprite and don’t care about unloading the attached
anm2 file, then use the Sprite.Reset method instead.
Since there is no official API method to clear specific layers from a sprite, we work around it
by setting the spritesheet to a transparent PNG file corresponding to the EMPTY_PNG_PATH
constant.
This function will still work identically if PNG file does not exist, but it will cause a
spurious error to appear in the “log.txt” file. If silencing these errors is desired, you can
create a transparent 1 pixel PNG file in your mod’s resources folder at EMPTY_PNG_PATH.
Parameters
Section titled “Parameters”sprite
Section titled “sprite”Sprite
layerIDs
Section titled “layerIDs”…readonly int[]
Returns
Section titled “Returns”void
Allow Empty Variadic
Section titled “Allow Empty Variadic”getLastFrameOfAnimation()
Section titled “getLastFrameOfAnimation()”getLastFrameOfAnimation(
sprite,animation?):int
Defined in: packages/isaacscript-common/src/functions/sprites.ts:50
Helper function that returns the number of the final frame in a particular animation for a sprite. By default, it will use the currently playing animation, but you can also specify a specific animation to check.
Note that this function is bugged with the Stop Watch or the Broken Watch, since using the
Sprite.SetFrame method will reset the internal accumulator used to slow down the playback speed
of the animation. (The PlaybackSpeed field of the sprite is not used.) Thus, it is only safe to
use this function on animations that are not slowed down by Stop Watch or Broken Watch, such as
player animations.
Parameters
Section titled “Parameters”sprite
Section titled “sprite”Sprite
animation?
Section titled “animation?”string
Returns
Section titled “Returns”int
newSprite()
Section titled “newSprite()”newSprite(
anm2Path,pngPath?):Sprite
Defined in: packages/isaacscript-common/src/functions/sprites.ts:81
Helper function to load a new sprite and play its default animation.
Parameters
Section titled “Parameters”anm2Path
Section titled “anm2Path”string
The path to the “anm2” file that should be loaded.
pngPath?
Section titled “pngPath?”string
Optional. The path to a custom PNG file that should be loaded on layer 0 of the sprite.
Returns
Section titled “Returns”Sprite
setSpriteOpacity()
Section titled “setSpriteOpacity()”setSpriteOpacity(
sprite,alpha):void
Defined in: packages/isaacscript-common/src/functions/sprites.ts:105
Helper function to keep a sprite’s color the same values as it already is but set the opacity to a specific value.
Parameters
Section titled “Parameters”sprite
Section titled “sprite”Sprite
The sprite to set.
float
A value between 0 and 1 that represents the fade amount.
Returns
Section titled “Returns”void
spriteEquals()
Section titled “spriteEquals()”spriteEquals(
sprite1,sprite2,layerID,xStart,xFinish,xIncrement,yStart,yFinish,yIncrement):boolean
Defined in: packages/isaacscript-common/src/functions/sprites.ts:118
Helper function to check if two sprite layers have the same sprite sheet by using the
Sprite.GetTexel method.
Since checking every single texel in the entire sprite is very expensive, this function requires that you provide a range of specific texels to check.
Parameters
Section titled “Parameters”sprite1
Section titled “sprite1”Sprite
sprite2
Section titled “sprite2”Sprite
layerID
Section titled “layerID”int
xStart
Section titled “xStart”int
xFinish
Section titled “xFinish”int
xIncrement
Section titled “xIncrement”int
yStart
Section titled “yStart”int
yFinish
Section titled “yFinish”int
yIncrement
Section titled “yIncrement”int
Returns
Section titled “Returns”boolean
texelEquals()
Section titled “texelEquals()”texelEquals(
sprite1,sprite2,position,layerID):boolean
Defined in: packages/isaacscript-common/src/functions/sprites.ts:144
Helper function to check if two texels on a sprite are equivalent to each other.
Parameters
Section titled “Parameters”sprite1
Section titled “sprite1”Sprite
sprite2
Section titled “sprite2”Sprite
position
Section titled “position”Vector
layerID
Section titled “layerID”int
Returns
Section titled “Returns”boolean
