-
Notifications
You must be signed in to change notification settings - Fork 1
AnimationManager
AnimationManager is a light-weight object that holds AnimationFlag(s) to designate the stop and start point of animations within a single sprite.
Constructor
| Name | Datatype | Purpose |
|---|---|---|
name |
string | Name of AnimationManager
|
sprite |
sprite_index | Sprite to use for animations |
[use_delta_time] |
boolean | Whether child flags use delta time |
Constructor that manages multiple animations on a single sprite through the use of flags. It's best to initialize the AnimationManager in the Create Event of the object that will be drawing the sprite.
flags is a DS Map that contains all of the animations specified as AnimationFlag.
Example:
// init animation manager
animator = new AnimationManager("Adventurer", spr_adventurer);AnimationManager('s) optional parameter, use_delta_time will accept a boolean variable flagging whether or not the child AnimationFlag(s) will use delta time during their calculations or not. If no value is passed for use_delta_time, a default value of ANIMATION_FLAGS_DELTA_TIME will be passed. ANIMATION_FLAGS_DELTA_TIME by default is false.
Example:
// init animation manager with delta time
animator = new AnimationManager("Adventurer", spr_adventurer, true);
Returns: N/A (undefined)
| Name | Datatype | Purpose |
|---|---|---|
flag |
struct | Flag to add to flags
|
[replace] |
boolean | Overwrites AnimationFlag with the same name if it exists in flags
|
Example:
// init animation manager
animator = new AnimationManager("Adventurer", spr_adventurer);
// add flag for "attack_1" animation
animator.add_flag(new AnimationFlag("attack_1", 0, 4, 0.15));
Returns: N/A (undefined)
| Name | Datatype | Purpose |
|---|---|---|
name |
string | Name of AnimationFlag to remove from flags
|
Finds the AnimationFlag from flags by name and deletes it. If the flag is not found, it will send a debug message.
Example:
// init animation manager
animator = new AnimationManager("Adventurer", spr_adventurer);
// add flag for "attack_1" animation
animator.add_flag(new AnimationFlag("attack_1", 0, 4, 0.15));
// remove flag for "attack_1" animation
animator.remove_flag("attack_1");
Returns: Struct, self
| Name | Datatype | Purpose |
|---|---|---|
name |
string | Name of AnimationFlag to set as active flag |
[reset] |
boolean |
AnimationFlag to reset its index to start
|
Returns the AnimationFlag from flags. If the flag is not found, it will send a debug message and return undefined.
Example:
// init animation manager
animator = new AnimationManager("Adventurer", spr_adventurer);
// add flag for "attack_1" animation
animator.add_flag(new AnimationFlag("attack_1", 0, 4, 0.15));
// sets active flag to "attack_1"
animator.set_flag("attack_1");
// get the active flag and store it in a variable
var active_flag = animator.get_active_flag();
Returns: Struct, that represents the name of the flag passed, N/A (undefined) if not found
| Name | Datatype | Purpose |
|---|---|---|
name |
string | Name of AnimationFlag
|
Finds the AnimationFlag from flags by name and returns it. If the flag is not found, it will send a debug message and return undefined.
Example:
// init animation manager
animator = new AnimationManager("Adventurer", spr_adventurer);
// add flag for "attack_1" animation
animator.add_flag(new AnimationFlag("attack_1", 0, 4, 0.15));
// get flag for "attack_1" animation and store it in a variable
var attack_1_flag = animator.get_flag("attack_1");
Returns: Struct, that represents the active_flag, N/A (undefined) if not found
| Name | Datatype | Purpose |
|---|---|---|
| None |
Returns the AnimationFlag from flags that represents the active_flag. If the flag is not found, it will send a debug message and return undefined.
Example:
// init animation manager
animator = new AnimationManager("Adventurer", spr_adventurer);
// add flag for "attack_1" animation
animator.add_flag(new AnimationFlag("attack_1", 0, 4, 0.15));
// sets active flag to "attack_1"
animator.set_flag("attack_1");
// get the active flag and store it in a variable
var active_flag = animator.get_active_flag();
Returns: Real, position of flag based on order, N/A (undefined) if not found
| Name | Datatype | Purpose |
|---|---|---|
name |
string | Name of AnimationFlag
|
Returns the position of AnimationFlag from flags that represents the order of the flag was added. Flag positions are base-0. This means the first flag added is at position 0.
If a flag is deleted, the position for flags that were added after the deleted flag will be shifted 1 position lower.
Example:
// init animation manager
animator = new AnimationManager("Adventurer", spr_adventurer);
// add flag for "attack_1" animation
animator.add_flag(new AnimationFlag("attack_1", 0, 4, 0.15));
// sets active flag to "attack_1"
animator.set_flag("attack_1");
// get the position of "attack_1" flag
var position = animator.get_flag_position("attack_1"); // 0
Returns: Struct, that represents the flag in position specified, N/A (undefined) if not found
| Name | Datatype | Purpose |
|---|---|---|
index |
real | Position of AnimationFlag to get |
Returns AnimationFlag struct that is at given position.
Example:
// init animation manager
animator = new AnimationManager("Adventurer", spr_adventurer);
// add flag for "attack_1" animation
animator.add_flag(new AnimationFlag("attack_1", 0, 4, 0.15));
// sets active flag to "attack_1"
animator.set_flag("attack_1");
// get the flat at position
var flag = animator.get_flag_at_position(0); // AnimationFlag<attack_1>
Returns: Boolean, whether the name of flag exists in flags
| Name | Datatype | Purpose |
|---|---|---|
name |
string | Name of AnimationFlag to check in flags
|
Checks whether a flag exists with the specified name and returns the result.
Example:
// init animation manager
animator = new AnimationManager("Adventurer", spr_adventurer);
// add flag for "attack_1" animation
animator.add_flag(new AnimationFlag("attack_1", 0, 4, 0.15));
// check if "attack_1" flag exists
var has_atk_1_anim = animator.flag_exists("attack_1");
Returns: Real, number of flags
| Name | Datatype | Purpose |
|---|---|---|
| None |
Returns number of flags.
Returns: String, name of sprite_index at sprite
| Name | Datatype | Purpose |
|---|---|---|
| None |
Returns the name of the sprite_index stored in sprite.
Example:
// init animation manager
animator = new AnimationManager("Adventurer", spr_adventurer);
// get sprite name and store it in a variable
var sprite_name = animator.get_sprite_name();
Returns: Struct, self
| Name | Datatype | Purpose |
|---|---|---|
use_delta_time |
Boolean | Whether child flags use delta timing |
Sets the use_delta_time variable, and returns self.
Example:
// init animation manager
animator = new AnimationManager("Adventurer", spr_adventurer);
// set animation manager to use delta time
animator.set_delta_time(true);
Returns: N/A (undefined)
| Name | Datatype | Purpose |
|---|---|---|
| None |
Cleans up all data structures when you no longer need the manager by destroying them. This function should be added to the Clean Up Event of the object to prevent memory leaks.
Returns: N/A (undefined)
| Name | Datatype | Purpose |
|---|---|---|
| None |
Runs the flag associated with active_flag and returns self. If active_flag is not set or not AnimationFlag exists that's associated with the name stored in active_flag.
Returns: N/A (undefined)
| Name | Datatype | Purpose |
|---|---|---|
msg |
string | Debug message to print in output |
Method used by the library to display information about the AnimationManager and the error message in the Output Window. This method is strictly for debugging.
Returns: String, printable representation of AnimationManager
| Name | Datatype | Purpose |
|---|---|---|
| None |
Returns a printable representation of the AnimationManager when wrapped by string().