Animation Functions (Global) - coldrockgames/gml-raptor GitHub Wiki
These functions will help you organize your Animations
and provide some shortcut- and convenience functions for common tasks.
/// @func animation_clear_pool()
/// @desc Instantly removes ALL animations from the global ANIMATIONS pool.
function animation_clear_pool() {
/// @func animation_get_all(owner = self)
/// @desc Get all registered animations for the specified owner from the global ANIMATIONS pool.
/// NOTE: Set the owner to <undefined> to retrieve ALL existing animations!
function animation_get_all(owner = self) {
/// @func animation_get(owner, name)
/// @desc Gets an animation by name.
/// @returns {Animation} undefined if missing
function animation_get(owner, name) {
/// @func animation_abort_all(owner = self, _run_finished_triggers = true)
/// @desc Remove all registered animations for the specified owner from the global ANIMATIONS pool.
/// NOTE: Set the owner to <undefined> to abort ALL existing animations!
function animation_abort_all(owner = self, _run_finished_triggers = true) {
/// @func animation_abort(owner, name, _run_finished_triggers = true)
/// @desc Aborts one specific named animation of a specified owner.
/// NOTE: If multiple animations with the same name exist,
/// only the first one found will be aborted!
/// @returns {bool} True, if an animation has been aborted, otherwise false.
function animation_abort(owner, name, _run_finished_triggers = true) {
/// @func animation_finish_all(owner = self)
/// @desc Finish all registered animations for the specified owner.
/// NOTE: Set the owner to <undefined> to finish ALL existing animations!
function animation_finish_all(owner = self) {
/// @func animation_finish(owner, name)
/// @desc Finishes one specific named animation of a specified owner.
/// NOTE: If multiple animations with the same name exist,
/// only the first one found will be finished!
/// @returns {bool} True, if an animation has been finished, otherwise false.
function animation_finish(owner, name) {
/// @func animation_pause_all(owner = self)
/// @desc Set all registered animations for the specified owner to paused state.
/// NOTE: Set the owner to <undefined> to pause ALL existing animations!
/// This bulk function is very handy if you have a "pause/resume" feature in your
/// game and you want to "freeze" the scene.
function animation_pause_all(owner = self) {
/// @func animation_resume_all(owner = self)
/// @desc Set all registered animations for the specified owner to running state.
/// NOTE: Set the owner to <undefined> to resume ALL existing animations!
/// This bulk function is very handy if you have a "pause/resume" feature in your
/// game and you want to "unfreeze" the scene.
function animation_resume_all(owner = self) {
/// @func is_in_animation(owner = self, name = undefined)
/// @desc Returns true, if there's at least one animation for the specified owner
/// currently in the global ANIMATIONS pool.
/// If the name is also specified, true is only returned, if the names match.
/// This is useful if you need to know, whether an object is currently running
/// one specific animation.
function is_in_animation(owner = self, name = undefined) {
/// @func animation_run(_obj_owner, _delay, _duration, _animcurve, _repeats = 1, _finished_state = undefined, _data = {})
/// @desc convenience constructor wrapper if you don't need to keep your own pointer
/// @param {instance} _obj_owner The object to be animated
/// @param {int} _delay How many frames to wait until animation starts
/// @param {int} _duration Running time of (one loop) of the animation
/// @param {AnimCurve} _animcurve The AnimCurve providing the animated values
/// @param {int} _repeats Number of loops to perform. Default = 1, set to -1 for infinite repeats.
/// @param {string} _finished_state If the owner is stateful (or owns a StateMachine named "states"),
/// you can supply the name of a state here to set when this animation
/// finishes (A finished_trigger will be added for you).
/// @returns {Animation}
function animation_run(_obj_owner, _delay, _duration, _animcurve, _repeats = 1, _finished_state = undefined, _data = {}) {
/// @func animation_run_ex(_obj_owner, _delay, _duration, _animcurve, _repeats = 1, _finished_state = undefined)
/// @desc Runs an animation EXCLUSIVE (i.e. calls "animation_abort_all()" for the owner first.
/// Convenience constructor wrapper if you don't need to keep your own pointer
/// @param {instance} _obj_owner The object to be animated
/// @param {int} _delay How many frames to wait until animation starts
/// @param {int} _duration Running time of (one loop) of the animation
/// @param {AnimCurve} _animcurve The AnimCurve providing the animated values
/// @param {int} _repeats Number of loops to perform. Default = 1, set to -1 for infinite repeats.
/// @param {string} _finished_state If the owner is stateful (or owns a StateMachine named "states"),
/// you can supply the name of a state here to set when this animation
/// finishes (A finished_trigger will be added for you).
/// @returns {Animation}
function animation_run_ex(_obj_owner, _delay, _duration, _animcurve, _repeats = 1, _finished_state = undefined, _data = {}) {
/// @func animate_sprite(_sprite, _layer_name_or_depth, _x, _y, _delay, _duration, _animcurve, _repeats = 1, _sprite_data = {}, _anim_data = {})
/// @desc Similar to animation run, it even returns an animation, but you don't need an object to animate,
/// instead, a sprite_index is enough and a pooled instance of __sprite_anim_runner will be used to
/// run the animation. It returns to the pool, when the animation is finished.
/// Works even for ANIMATION CHAINS! That's why this function returns the created animation and not
/// the pooled runner object. You can obtain the pooled runner object from the .owner property of the
/// animation returned.
/// NOTE: There are 2 structs you may supply:
/// _sprite_data will be sent to the onPoolActivate of the __sprite_anim_runner. You can modify the sprite
/// with this struct. All green image_* variables (index, blend, speed, alpha, angle, scale) will
/// be taken into account
/// _anim_data will be sent to the created Animation as data object and is available in all your triggers you
/// attach to the animation
/// @returns {Animation}
function animate_sprite(_sprite, _layer_name_or_depth, _x, _y, _delay, _duration, _animcurve, _repeats = 1, _sprite_data = {}, _anim_data = {}) {
Continue in abort() vs finish().