Skip to content

Animations

Functions

Animation Count

Returns the number of Animations within an Animation Script.

Parameters:

NameTypeDescription
scriptAnimation ScriptThe Animation Script to count the animations in.

Return Type: Integer

Signatures:

int animation_count(animation_script script)

Animation Current Cell

Returns the current cell (the part of the image or sprite) of this animation. This can be used to animate an image or sprite.

Parameters:

NameTypeDescription
animAnimationThe Animation to return the cell of.

Return Type: Integer

Signatures:

int animation_current_cell(animation anim)

Animation Current Vector

Returns the Vector 2d assigned to the current frame in the animation.

Parameters:

NameTypeDescription
animAnimationThe animation to check the vector of.

Return Type: Vector 2d

Signatures:

vector_2d animation_current_vector(animation anim)

Animation Ended

Checks if an Animation has ended.

Parameters:

NameTypeDescription
animAnimationThe animation to check.

Return Type: Boolean

Signatures:

bool animation_ended(animation anim)

Animation Entered Frame

Returns true if the Animation entered a new frame on its last update. This can be used to trigger actions on frames within an animation.

Parameters:

NameTypeDescription
animAnimationThe animation to check.

Return Type: Boolean

Signatures:

bool animation_entered_frame(animation anim)

Animation Frame Time

Returns the amount of time spent in the current frame. When this exceeds the frames duration the animation moves to the next frame.

Parameters:

NameTypeDescription
animAnimationThe animation to check.

Return Type: Float

Signatures:

float animation_frame_time(animation anim)

Animation Index

Searches an Animation Script for an Animation and returns its index.

Parameters:

NameTypeDescription
scriptAnimation ScriptThe Animation Script to look for the Animation in.
nameStringThe name of the Animation to look for.

Return Type: Integer

Signatures:

int animation_index(animation_script script, const string &name)

Animation Name

Searches an Animation Script for an animation and returns its name.

Parameters:

NameTypeDescription
tempAnimationThe Animation to search for.

Return Type: String

Usage:

Signatures:

string animation_name(animation temp)

Animation Script Name

Retuns the name of an Animation Script.

Parameters:

NameTypeDescription
scriptAnimation ScriptThe Animation Script to return the name of.

Return Type: String

Signatures:

string animation_script_name(animation_script script)

Animation Script Named

Loads and returns a Animation Script. The supplied filename is used to locate the Animation Script to load. The supplied name indicates the name to use to refer to this in SplashKit. The Animation Script can then be retrieved by passing this name to the animation_script_named method.

Parameters:

NameTypeDescription
nameStringIndicates the name used to locate the animation_script to load

Return Type: Animation Script

Usage:

Signatures:

animation_script animation_script_named(const string &name)

Assign Animation

Assign Animation

Setup an Animation to follow the script from an indicated name. This will switch the animation to use the supplied script. It locates the name of the animation with the animation script and sets the anim to start at that point in the script.

Parameters:

NameTypeDescription
animAnimationThe Animation to be assigned.
scriptAnimation ScriptThe Animation Script to assign the Animation to.
nameStringThe name of the Animation to be assigned.

Signatures:

void assign_animation(animation anim, animation_script script, const string &name)

Assign Animation

Assigns an Animation to an Animation Script. This may play a sound effect if the animation is set to play a sound effect on its first frame.

Parameters:

NameTypeDescription
animAnimationThe Animation to be assigned.
scriptAnimation ScriptThe Animation Script to assign the Animation to.
nameStringThe name of the Animation to be assigned.
with_soundBooleanDenotes whether the Animation should play audio.

Signatures:

void assign_animation(animation anim, animation_script script, const string &name, bool with_sound)

Assign Animation

Assigns an Animation to an Animation Script.

Parameters:

NameTypeDescription
animAnimationThe Animation to be assigned.
scriptAnimation ScriptThe Animation Script to assign the Animation to.
idxIntegerThe index of the Animation to create.

Signatures:

void assign_animation(animation anim, animation_script script, int idx)

Assign Animation

Assigns an Animation to an Animation Script. This may play a sound effect if the animation is set to play a sound effect on its first frame.

Parameters:

NameTypeDescription
animAnimationThe Animation to be assigned.
scriptAnimation ScriptThe Animation Script to assign the Animation to.
idxIntegerThe index of the Animation to create.
with_soundBooleanDenotes whether the Animation should play audio.

Signatures:

void assign_animation(animation anim, animation_script script, int idx, bool with_sound)

Assign Animation

Assigns an Animation to an Animation Script.

Parameters:

NameTypeDescription
animAnimationThe Animation to be assigned.
script_nameStringThe name of the Animation Script to assign the Animation to.
nameStringThe name of the Animation to be assigned.

Signatures:

void assign_animation(animation anim, const string &script_name, const string &name)

Assign Animation

Assigns an Animation to an Animation Script. This may play a sound effect if the animation is set to play a sound effect on its first frame.

Parameters:

NameTypeDescription
animAnimationThe Animation to be assigned.
script_nameStringThe name of the Animation Script to assign the Animation to.
nameStringThe name of the Animation to be assigned
with_soundBooleanDenotes whether the Animation should play audio.

Signatures:

void assign_animation(animation anim, const string &script_name, const string &name, bool with_sound)

Assign Animation

Setup an Animation to follow the script from an indicated index. This uses the index from the current animation script and sets the supplied animation to start at that point in the script.

Parameters:

NameTypeDescription
animAnimationThe Animation to be assigned.
idxIntegerThe index of the animation to use from its current script.

Signatures:

void assign_animation(animation anim, int idx)

Assign Animation

Setup an Animation to follow the script from an indicated index. This uses the index from the current animation script and sets the supplied animation to start at that point in the script.

Parameters:

NameTypeDescription
animAnimationThe Animation to be assigned.
idxIntegerThe index of the animation to use from its current script.
with_soundBooleanDenotes whether the Animation should play audio.

Signatures:

void assign_animation(animation anim, int idx, bool with_sound)

Assign Animation

Setup an Animation to follow the script from an indicated name. This locates the name of the animation from the current animation script and sets the supplied animation to start at that point in the script.

Parameters:

NameTypeDescription
animAnimationThe Animation to be assigned.
nameStringThe name of the animation to use from its current script.

Usage:

Signatures:

void assign_animation(animation anim, string name)

Assign Animation

Setup an Animation to follow the script from an indicated name. This locates the name of the animation from the current animation script and sets the supplied animation to start at that point in the script.

Parameters:

NameTypeDescription
animAnimationThe Animation to be assigned.
nameStringThe name of the animation to use from its current script.
with_soundBooleanDenotes whether the Animation should play audio.

Signatures:

void assign_animation(animation anim, string name, bool with_sound)

Create Animation

Create Animation

Creates an animation from an Animation Script. This may play a sound effect if the animation is set to play a sound effect on its first frame.

Parameters:

NameTypeDescription
scriptAnimation ScriptThe Animation Script to create the Animation from.
idxIntegerThe index of the Animation to create.
with_soundBooleanDenotes whether the Animation should play audio.

Return Type: Animation

Signatures:

animation create_animation(animation_script script, int idx, bool with_sound)

Create Animation

Creates an animation from an Animation Script.

Parameters:

NameTypeDescription
scriptAnimation ScriptThe Animation Script to create the Animation from
nameStringThe name for the new Animation

Return Type: Animation

Signatures:

animation create_animation(animation_script script, const string &name)

Create Animation

Creates an animation from a Animation Script. This may play a sound effect if the animation is set to play a sound effect on its first frame.

Parameters:

NameTypeDescription
scriptAnimation ScriptThe Animation Script to create the Animation from
nameStringThe name for the new Animation
with_soundBooleanDenotes whether the Animation should play audio.

Return Type: Animation

Signatures:

animation create_animation(animation_script script, const string &name, bool with_sound)

Create Animation

Creates an animation from an Animation Script’s name. This may play a sound effect if the animation is set to play a sound effect on its first frame.

Parameters:

NameTypeDescription
script_nameStringThe name of the Animation Script to create the Animation from
nameStringThe name for the new Animation

Return Type: Animation

Usage:

Signatures:

animation create_animation(const string &script_name, const string &name)

Create Animation

Creates an animation from an Animation Script’s name. This may play a sound effect if the animation is set to play a sound effect on its first frame.

Parameters:

NameTypeDescription
script_nameStringThe name of the Animation Script to create the Animation from
nameStringThe name for the new Animation
with_soundBooleanDenotes whether the Animation should play audio.

Return Type: Animation

Signatures:

animation create_animation(const string &script_name, const string &name, bool with_sound)

Free All Animation Scripts

Frees all loaded Animation Scripts.

Signatures:

void free_all_animation_scripts()

Free Animation

Disposes of the resources used in the animation.

Parameters:

NameTypeDescription
aniAnimationThe Animation to be disposed of.

Signatures:

void free_animation(animation ani)

Free Animation Script

Free Animation Script

Frees loaded animation frames data. Use this when you will no longer be using the animation for any purpose, including within sprite.

Parameters:

NameTypeDescription
script_to_freeAnimation ScriptThe Animation Script to be freed.

Signatures:

void free_animation_script(animation_script script_to_free)

Free Animation Script

Frees loaded Animation Script data. Use this when you will no longer be using the animation for any purpose, including within sprite.

Parameters:

NameTypeDescription
nameStringThe name of the Animation Script to be freed.

Signatures:

void free_animation_script(const string &name)

Has Animation Named

Returns whether an Animation Script has been loaded with the given name.

Parameters:

NameTypeDescription
scriptAnimation ScriptThe Animation Script to check.
nameStringThe name of the Animation Script to look for.

Return Type: Boolean

Signatures:

bool has_animation_named(animation_script script, const string &name)

Has Animation Script

Determines if SplashKit has animation frames loaded for the supplied name. This checks against all loaded animation frames, those loaded without a name are assigned the filename as a default.

Parameters:

NameTypeDescription
nameStringThe name of the animation script to look for.

Return Type: Boolean

Signatures:

bool has_animation_script(const string &name)

Load Animation Script

Load animation details from an animation frames file.

Parameters:

NameTypeDescription
nameStringThe name of the Animation Script.
filenameStringThe file to load the Animation Script from.

Return Type: Animation Script

Signatures:

animation_script load_animation_script(const string &name, const string &filename)

Restart Animation

Restart Animation

Restarts an Animation.

Parameters:

NameTypeDescription
animAnimationThe Animation to restart.

Signatures:

void restart_animation(animation anim)

Restart Animation

Restarts an Animation. This may play a sound effect if the first frame triggers a sound.

Parameters:

NameTypeDescription
animAnimationThe Animation to restart.
with_soundBooleanDenotes whether the Animation should play audio.

Signatures:

void restart_animation(animation anim, bool with_sound)

Update Animation

Update Animation

Updates the animation, updating the time spent and possibly moving to a new frame in the animation. This may play a sound effect if the new frame triggers a sound.

Parameters:

NameTypeDescription
animAnimationThe Animation to update.
pctFloatThe amount that the frame time will be incremented
with_soundBooleanDenotes whether the Animation should play audio.

Signatures:

void update_animation(animation anim, float pct, bool with_sound)

Update Animation

Updates the animation, updating the time spent and possibly moving to a new frame in the animation. This may play a sound effect if the new frame triggers a sound.

Parameters:

NameTypeDescription
animAnimationThe Animation to update.

Usage:

Signatures:

void update_animation(animation anim)

Update Animation

Updates the animation, updating the time spent and possibly moving to a new frame in the animation. This may play a sound effect if the new frame triggers a sound.

Parameters:

NameTypeDescription
animAnimationThe Animation to update.
pctFloatThe amount that the frame time will be incremented

Signatures:

void update_animation(animation anim, float pct)