Hatch Game Engine Documentation v1.4.0
The documentation for the Hatch Game Engine
Loading...
Searching...
No Matches
Sprite Class Reference

Functions to retrieve information about sprites. More...

Public Member Functions

integer GetAnimationCount (integer sprite)
 Gets the amount of animations in the sprite.
string GetAnimationName (integer sprite, integer animationIndex)
 Gets the name of the specified animation index in the sprite.
integer GetAnimationIndexByName (integer sprite, string name)
 Gets the first animation in the sprite which matches the specified name.
boolean GetFrameExists (integer sprite, integer animation, integer frame)
 Checks if an animation and frame is valid within a sprite.
integer GetFrameLoopIndex (integer sprite, integer animation)
 Gets the index of the frame that the specified animation will loop back to when it finishes.
integer GetFrameCount (integer sprite, integer animation)
 Gets the amount of frames in the specified animation.
integer GetFrameDuration (integer sprite, integer animation, integer frame)
 Gets the frame duration of the specified sprite frame.
integer GetFrameSpeed (integer sprite, integer animation)
 Gets the animation speed of the specified animation.
integer GetFrameWidth (integer sprite, integer animation, integer frame)
 Gets the frame width of the specified sprite frame.
integer GetFrameHeight (integer sprite, integer animation, integer frame)
 Gets the frame height of the specified sprite frame.
integer GetFrameID (integer sprite, integer animation, integer frame)
 Gets the frame ID of the specified sprite frame.
integer GetFrameOffsetX (integer sprite, integer animation, integer frame)
 Gets the X offset of the specified sprite frame.
integer GetFrameOffsetY (integer sprite, integer animation, integer frame)
 Gets the Y offset of the specified sprite frame.
string GetHitboxName (integer sprite, integer animationID, integer frame, integer hitboxID)
 Gets the name of a hitbox through its index.
integer GetHitboxIndex (integer sprite, integer animationID, integer frame, string name)
 Gets the index of a hitbox by its name.
integer GetHitboxCount (integer sprite, integer animationID, integer frame)
 Gets the hitbox count in the given frame of an animation of a sprite.
hitbox GetHitbox (Entity entity, string hitbox)
 Gets the hitbox of a sprite frame.
hitbox GetHitbox (Entity entity, integer hitbox=0)
 Gets the hitbox of a sprite frame.
hitbox GetHitbox (integer sprite, integer animationID, integer frameID, string hitbox)
 Gets the hitbox of a sprite frame.
hitbox GetHitbox (integer sprite, integer animationID, integer frameID, integer hitbox=0)
 Gets the hitbox of a sprite frame.
array GetTextArray (integer sprite, integer animation, string text)
 Converts a string to an array of sprite indexes by comparing codepoints to a frame's ID.
void GetTextWidth (integer sprite, integer animation, array text, integer startIndex, integer spacing)
 Gets the width (in pixels) of a converted sprite string.
void MakePalettized (integer sprite, integer paletteIndex)
 Converts a sprite's colors to the ones in the specified palette index.
void MakeNonPalettized (integer sprite)
 Removes a sprite's palette.

Detailed Description

Functions to retrieve information about sprites.

Member Function Documentation

◆ GetAnimationCount()

integer Sprite.GetAnimationCount ( integer sprite)

Gets the amount of animations in the sprite.

Parameters
spriteThe sprite index to check.
Returns
Returns the amount of animations in the sprite.

◆ GetAnimationIndexByName()

integer Sprite.GetAnimationIndexByName ( integer sprite,
string name )

Gets the first animation in the sprite which matches the specified name.

Parameters
spriteThe sprite index to check.
nameThe animation name to search for.
Returns
Returns the first animation index with the specified name, or -1 if there was no match.

◆ GetAnimationName()

string Sprite.GetAnimationName ( integer sprite,
integer animationIndex )

Gets the name of the specified animation index in the sprite.

Parameters
spriteThe sprite index to check.
animationIndexThe animation index.
Returns
Returns the name of the specified animation index.

◆ GetFrameCount()

integer Sprite.GetFrameCount ( integer sprite,
integer animation )

Gets the amount of frames in the specified animation.

Parameters
spriteThe sprite index to check.
animationThe animation index of the sprite to check.
Returns
Returns the frame count in the specified animation.

◆ GetFrameDuration()

integer Sprite.GetFrameDuration ( integer sprite,
integer animation,
integer frame )

Gets the frame duration of the specified sprite frame.

Parameters
spriteThe sprite index to check.
animationThe animation index of the sprite to check.
frameThe frame index of the animation to check.
Returns
Returns the frame duration (in game frames) of the specified sprite frame.

◆ GetFrameExists()

boolean Sprite.GetFrameExists ( integer sprite,
integer animation,
integer frame )

Checks if an animation and frame is valid within a sprite.

Parameters
spriteThe sprite index to check.
animationThe animation index to check.
frameThe sprite index to check.
Returns
Returns whether the frame is valid.

◆ GetFrameHeight()

integer Sprite.GetFrameHeight ( integer sprite,
integer animation,
integer frame )

Gets the frame height of the specified sprite frame.

Parameters
spriteThe sprite index to check.
animationThe animation index of the sprite to check.
frameThe frame index of the animation to check.
Returns
Returns the frame height (in pixels) of the specified sprite frame.

◆ GetFrameID()

integer Sprite.GetFrameID ( integer sprite,
integer animation,
integer frame )

Gets the frame ID of the specified sprite frame.

Parameters
spriteThe sprite index to check.
animationThe animation index of the sprite to check.
frameThe frame index of the animation to check.
Returns
Returns the frame ID of the specified sprite frame.

◆ GetFrameLoopIndex()

integer Sprite.GetFrameLoopIndex ( integer sprite,
integer animation )

Gets the index of the frame that the specified animation will loop back to when it finishes.

Parameters
spriteThe sprite index to check.
animationThe animation index of the sprite to check.
Returns
Returns the frame loop index.

◆ GetFrameOffsetX()

integer Sprite.GetFrameOffsetX ( integer sprite,
integer animation,
integer frame )

Gets the X offset of the specified sprite frame.

Parameters
spriteThe sprite index to check.
animationThe animation index of the sprite to check.
frameThe frame index of the animation to check.
Returns
Returns the X offset of the specified sprite frame.

◆ GetFrameOffsetY()

integer Sprite.GetFrameOffsetY ( integer sprite,
integer animation,
integer frame )

Gets the Y offset of the specified sprite frame.

Parameters
spriteThe sprite index to check.
animationThe animation index of the sprite to check.
frameThe frame index of the animation to check.
Returns
Returns the Y offset of the specified sprite frame.

◆ GetFrameSpeed()

integer Sprite.GetFrameSpeed ( integer sprite,
integer animation )

Gets the animation speed of the specified animation.

Parameters
spriteThe sprite index to check.
animationThe animation index of the sprite to check.
Returns
Returns an integer.

◆ GetFrameWidth()

integer Sprite.GetFrameWidth ( integer sprite,
integer animation,
integer frame )

Gets the frame width of the specified sprite frame.

Parameters
spriteThe sprite index to check.
animationThe animation index of the sprite to check.
frameThe frame index of the animation to check.
Returns
Returns the frame width (in pixels) of the specified sprite frame.

◆ GetHitbox() [1/4]

hitbox Sprite.GetHitbox ( Entity entity,
integer hitbox = 0 )

Gets the hitbox of a sprite frame.

Parameters
entityAn entity with Sprite, CurrentAnimation, and CurrentFrame values.
hitboxThe hitbox index.
Returns
Returns a Hitbox value.

◆ GetHitbox() [2/4]

hitbox Sprite.GetHitbox ( Entity entity,
string hitbox )

Gets the hitbox of a sprite frame.

Parameters
entityAn entity with Sprite, CurrentAnimation, and CurrentFrame values.
hitboxThe hitbox name.
Returns
Returns a Hitbox value.

◆ GetHitbox() [3/4]

hitbox Sprite.GetHitbox ( integer sprite,
integer animationID,
integer frameID,
integer hitbox = 0 )

Gets the hitbox of a sprite frame.

Parameters
spriteThe sprite index to check.
animationIDThe animation index of the sprite to check.
frameIDThe frame index of the animation to check.
hitboxThe hitbox index.
Returns
Returns a Hitbox value.

◆ GetHitbox() [4/4]

hitbox Sprite.GetHitbox ( integer sprite,
integer animationID,
integer frameID,
string hitbox )

Gets the hitbox of a sprite frame.

Parameters
spriteThe sprite index to check.
animationIDThe animation index of the sprite to check.
frameIDThe frame index of the animation to check.
hitboxThe hitbox name.
Returns
Returns a Hitbox value.

◆ GetHitboxCount()

integer Sprite.GetHitboxCount ( integer sprite,
integer animationID,
integer frame )

Gets the hitbox count in the given frame of an animation of a sprite.

Parameters
spriteThe sprite index to check.
animationIDThe animation index of the sprite to check.
frameThe frame index of the animation to check.
Returns
Returns an integer value.

◆ GetHitboxIndex()

integer Sprite.GetHitboxIndex ( integer sprite,
integer animationID,
integer frame,
string name )

Gets the index of a hitbox by its name.

Parameters
spriteThe sprite index to check.
animationIDThe animation index of the sprite to check.
frameThe frame index of the animation to check.
nameThe name of the hitbox to check.
Returns
Returns an integer value, or null if no such hitbox exists with that name.

◆ GetHitboxName()

string Sprite.GetHitboxName ( integer sprite,
integer animationID,
integer frame,
integer hitboxID )

Gets the name of a hitbox through its index.

Parameters
spriteThe sprite index to check.
animationIDThe animation index of the sprite to check.
frameThe frame index of the animation to check.
hitboxIDThe hitbox index to check.
Returns
Returns a string value.

◆ GetTextArray()

array Sprite.GetTextArray ( integer sprite,
integer animation,
string text )

Converts a string to an array of sprite indexes by comparing codepoints to a frame's ID.

Parameters
spriteThe sprite index.
animationThe animation index containing frames with codepoint ID values.
textThe text to convert.
Returns
Returns an array of sprite indexes per character in the text.

◆ GetTextWidth()

void Sprite.GetTextWidth ( integer sprite,
integer animation,
array text,
integer startIndex,
integer spacing )

Gets the width (in pixels) of a converted sprite string.

Parameters
spriteThe sprite index.
animationThe animation index.
textThe array containing frame indexes.
startIndexWhere to start checking the width.
spacingThe spacing (in pixels) between frames.

◆ MakeNonPalettized()

void Sprite.MakeNonPalettized ( integer sprite)

Removes a sprite's palette.

Parameters
spriteThe sprite index.

◆ MakePalettized()

void Sprite.MakePalettized ( integer sprite,
integer paletteIndex )

Converts a sprite's colors to the ones in the specified palette index.

Parameters
spriteThe sprite index.
paletteIndexThe palette index.