Skip to content

Functions

Ali El Saleh edited this page May 14, 2019 · 13 revisions

List of all available functions

Constructor

Animator

(
    const char* AnimatorName, 
    unsigned int NumOfFramesPerRow, 
    unsigned int NumOfRows, 
    unsigned int Speed, 
    bool bPlayInReverse = false, 
    bool bContinuous = false, 
    bool bLooping = true 
)

Creates an animator instance.

AnimatorName: A name the animator will be identified by.
NumOfFramesPerRow: The amount of frames/columns in a row.
NumOfRows: The amount of rows in the sprite sheet.
Speed: The animation speed in frames per second.
bPlayInReverse: Should the animator play the sprite in reverse play mode?
bContinuous: Should the animator automatically go to the next row in the sprite sheet?
bLooping: Should the animator loop indefinitely?

Setters

void AssignSprite

(        
    const Texture2D& Sprite 
)  

Assigns a sprite for the animator to use. (This should be called once)

Sprite: The sprite the animator will use.


void SetLooping

(
    const bool bLooping
)  

Set whether the animator should loop or not.

bLooping: Should the animator loop?


void SetContinuous

(
    const bool bIsContinuous
)  

Set whether the animator should go to the next row in the sprite sheet or not.

bIsContinuous: Should the animator continue to the next row?


void SetFramerate

(
    const unsigned int Framerate
)  

Set a new framerate the animator will use.

Framerate: The new speed of animation.

Getters

Texture2D GetSprite() const

Returns: The sprite texture.


Rectangle GetFrameRec() const

Returns: The Frame rectangle. (Used for drawing the sprite)


unsigned int GetTotalFrames() const

Returns: The total amount of frames in the sprite-sheet.


unsigned int GetTotalRows() const

Returns: The total rows in the sprite-sheet.


unsigned int GetTotalColumns() const

Returns: The total columns per row.


unsigned int GetCurrentFrame() const

Returns: The current frame the animator is on. (Zero based)


unsigned int GetCurrentRow() const

Returns: The current row the animator is on. (Zero based)


unsigned int GetCurrentColumn() const

Returns: The current column the animator is on. (Zero based)


unsigned int GetTotalTimeInFrames() const

Returns: The total time the animation will take to finish in frames.


unsigned int GetTimeRemainingInFrames() const

Returns: The time remaining in frames.


float GetTotalTimeInSeconds() const;

Returns: The total time the animation will take to finish in seconds.


float GetTimeRemainingInSeconds() const

Returns: The time remaining in seconds.


const char* GetName() const

Returns: The name of the animator.


Utilities

void ChangeSprite

(
    const Texture2D& NewSprite, 
    unsigned int NumOfFramesPerRow, 
    unsigned int NumOfRows, 
    unsigned int Speed, 
    float DelayInSeconds = 0.0f, 
    bool bPlayInReverse = false, 
    bool bContinuous = false, 
    bool bLooping = true
)

Changes the sprite the animator is using.

NewSprite: The new sprite the animator will change to. Will reset to beginning frame.
NumOfFramesPerRow: The amount of frames/columns in a row.
NumOfRows: The amount of rows in the sprite sheet.
Speed: The animation speed in frames per second.
DelayInSeconds: The amount of time (in seconds) to change to the new sprite. A value of 0.0f is instant/no delay.
bPlayInReverse: Should the animator play the new sprite in reverse play mode?
bContinuous: Should the animator automatically go to the next row in the sprite sheet?
bLooping: Should the animator loop indefinitely?


void FlipSprite

(
    bool bHorizontalFlip, 
    bool bVerticalFlip = true
)

Flips the sprite-sheet horizontally or vertically, or both.

bHorizontalFlip: Flips the sprite sheet horizontally. DOES NOT WORK, set this to false.
bVerticalFlip: Flips the sprite sheet vertically.


void GoToFrame

(
    const unsigned int FrameNumber
)

Jump to a frame in the sprite-sheet.

FrameNumber: The frame number in the sprite sheet. (Zero-based)


void GoToRow

(
    const unsigned int RowNumber
)

Jump to a row in the sprite-sheet.

RowNumber: The row number in the sprite sheet. (Zero-based)


void GoToColumn

(
    const unsigned int ColumnNumber
)

Jump to a column in the current row.

ColumnNumber: The column number in the sprite sheet. (Zero-based)


void GoToFirstRow()

Jump to the first row.


void GoToFirstColumn()

Jump to the first column.


void GoToLastRow()

Jump to the last row.


void GoToLastColumn()

Jump to the last column.


void GoToFirstFrame()

Jump to the first frame in the current row.


void GoToLastFrame()

Jump to the last frame in the current row.


void GoToFirstFrameOfSpriteSheet()

Jump to the first frame in the sprite sheet.


void GoToLastFrameOfSpriteSheet()

Jump to the last frame in the sprite sheet.


void NextRow()

Jump to the next row index.


void PreviousRow()

Jump to the previous row index.


void NextColumn()

Jump to the next column index.


void PreviousColumn()

Jump to the previous column index.

Playback Controls

void Play()

Play animation from the current frame.


void Start()

Start the animation when it has been paused or has been stopped.


void Stop()

Stop the animation from playing.


void Pause

(
    const bool bToggle = false
)  

Pause the animation.

bToggle: If true, flip-flop between pausing and un-pausing the animation every time when called. If false, pause the animation. You need to call UnPause to start the animation again.


void UnPause()

UnPause the animation. (Start playing)


void Forward()

Set the play mode to forward.


void Reverse

(
    const bool bToggle = false
)

Set the play mode to reverse.

bToggle: If true, flip-flop between reversing and un-reversing the play mode every time when called. If false, reverse the play mode. You need to call Forward to un-reverse.


void Restart()

Restart the animation from the beginning.

Queries

bool IsAtFrame const

(
    const unsigned int FrameNumber
)

Is the animator currently on the frame number specified?

FrameNumber: The frame number to query. (Zero based)
Returns: If the animator is on the frame number specified, true. Otherwise, false.


bool IsAtRow const

(
    const unsigned int RowNumber
)

Is the animator currently on the row number specified?

RowNumber: The row number to query. (Zero based)
Returns: If the animator is on the row number specified, true. Otherwise, false.


bool IsAtColumn const

(
    const unsigned int ColumnNumber
)

Is the animator currently on the column number specified?

ColumnNumber: The column number to query. (Zero based)
Returns: If the animator is on the column number specified, true. Otherwise, false.


bool IsAtFirstFrameOfSpriteSheet() const

Is the animator currently on the first frame of the sprite-sheet?

Returns: If the animator is on the first frame of the sprite-sheet, true. Otherwise, false.


bool IsAtLastFrameOfSpriteSheet() const

Is the animator currently on the last frame of the sprite-sheet?

Returns: If the animator is on the last frame of the sprite-sheet, true. Otherwise, false.


bool IsAtFirstFrame() const

Is the animator currently on the first frame of a current row?

Returns: If the animator is on the first frame, true. Otherwise, false.


bool IsAtLastFrame() const

Is the animator currently on the last frame of a current row?

Returns: If the animator is on the last frame, true. Otherwise, false.


bool IsAtFirstRow() const

Is the animator currently on the first row of the sprite-sheet?

Returns: If the animator is on the first row, true. Otherwise, false.


bool IsAtLastRow() const

Is the animator currently on the last row of the sprite-sheet?

Returns: If the animator is on the last row, true. Otherwise, false.


bool IsAtFirstColumn() const

Is the animator currently on the first column of a current row?

Returns: If the animator is on the first column, true. Otherwise, false.


bool IsAtLastColumn() const

Is the animator currently on the last column of a current row?

Returns: If the animator is on the last column, true. Otherwise, false.


bool IsPlaying() const

Is the animator currently playing?

Returns: If the animator is currently playing, true. Otherwise, false.


bool IsStartedPlaying() const

Has the animator started playing?

Returns: If the animator started playing, true. Otherwise, false.


bool IsFinishedPlaying() const

Has the animator finished playing?

Returns: If the animator finished playing, true. Otherwise, false.

Clone this wiki locally