Creates and plays a tween which eases one or more properties/variables between two values over a set duration of time. Tween is automatically destroyed when finished playing, stopped, or if its associated target instance/struct is destroyed. For experienced users, please see Advanced Features for greater control and flexibility. Please be cautious when using explicit Struct Targets for tweens. You can read more about that here: Warning about Struct Targets TweenFire(target, ease, mode, delta, delay, dur, prop, start, dest, [...]) |
target | Instance or struct to associate with tween and its properties |
ease | Easing function (EaseInOutSine), easing name ("InOutSine"), or animation curve id/channel |
mode | Play mode number/macro (0-4, TWEEN_MODE_*) or string ("once", "patrol", etc) |
delta | Whether to set timing in seconds(true) or steps (false) |
delay | Duration of time to delay start of tween |
dur | Duration of time to ease property from start to destination |
prop | Property variable string (e.g. "x", "direction", "speed") |
start | Starting value of eased property |
dest | Destination value of eased property |
[...] | Additional properties (in order: prop,start,dest) |
Returns: tween id Example
|
Allows for chaining of tweens by adding a tween to be fired after the indicated tween finishes. Multiple new tweens can be added to the same tween, allowing for branching chains. Tween is automatically destroyed when finished, stopped, or if its associated target instance is destroyed. For experienced users, please see Advanced Features for greater control and flexibility. NOTE: If TweenMore() is used with a tween created by TweenCreate(), then the tween will remain persistent like the base tween created with TweenCreate(). TweenMore(tween, target, ease, mode, delta, delay, dur, prop, start, dest, [...]) |
tween | Tween id |
target | Instance or struct to associate with tween and its properties |
ease | Easing function (EaseInOutSine), easing name ("InOutSine"), or animation curve id/channel |
mode | Play mode number/macro (0-4, TWEEN_MODE_*) or string ("once", "patrol", etc) |
delta | Whether to set timing in seconds(true) or steps (false) |
delay | Duration of time to delay start of tween |
dur | Duration of time to ease property from start to destination |
prop | Property variable string (e.g. "x", "direction", "speed") |
start | Starting value of eased property |
dest | Destination value of eased property |
[...] | Additional properties (in order: prop,start,dest) |
Returns: tween id Example
|
Creates and returns a tween to be played at a later time with TweenPlay(). It will prepare one or more properties to be eased between two values over a set duration of time. The created tween will continue to exist and be valid until its associated target is destroyed. But it can also be manually destroyed with TweenDestroy(). Tweens can be defined (all parameters set) or undefined (only target is set) at creation. Please be cautious when using explicit Struct Targets for tweens. You can read more about that here: Warning about Struct Targets TweenCreate(target, [ease, mode, delta, delay, dur, prop, start, dest, ...]) |
target | Instance or struct to associate with tween and its properties |
ease | Easing function (EaseInOutSine), easing name ("InOutSine"), or animation curve id/channel |
mode | Play mode number/macro (0-4, TWEEN_MODE_*) or string ("once", "patrol", etc) |
delta | Whether to set timing in seconds(true) or steps (false) |
delay | Duration of time to delay start of tween |
dur | Duration of time to ease property from start to destination |
prop | Property variable string (e.g. "x", "direction", "speed") |
start | Starting value of eased property |
dest | Destination value of eased property |
[...] | Additional properties (in order: prop,start,dest) |
Returns: tween id Example
|
Starts playing tween[s] previously created with TweenCreate(). Can optionally override a predefined tween. This can also be used to restart a tween, even ones created with TweenFire(). This function supports Tween Selection for starting multiple tweens at once. TweenPlay(tween[s], [ease, mode, delta, delay, dur, prop, start, dest, ...]) |
tween[s] | Tween id or Tween Selection |
ease | Easing function (EaseInOutSine), easing name ("InOutSine"), or animation curve id/channel |
mode | Play mode number/macro (0-4, TWEEN_MODE_*) or string ("once", "patrol", etc) |
delta | Whether to set timing in seconds(true) or steps (false) |
delay | Duration of time to delay start of tween |
dur | Duration of time to ease property from start to destination |
prop | Property variable string (e.g. "x", "direction", "speed") |
start | Starting value of eased property |
dest | Destination value of eased property |
[...] | Additional properties (in order: prop,start,dest) |
Returns: na Example
|
Starts playing defined tween[s] previously created with TweenCreate() after a set duration of time. This function supports Tween Selection for starting multiple tweens at once. TweenPlayDelay(tween[s], delay) |
tween[s] | Tween id or Tween Selection |
delay | Duration of time to delay start of tween |
Returns: na Example
|
Schedules a script, function, or method to be executed after a set duration of time. Returns a tween id handle so it can be manipulated like other regular tweens. This means you can call functions like TweenPause(), TweenResume(), or even TweenAddCallback() on returned handles. TweenScript(target, delta, dur, script, [arg0, ...]) |
target | Instance or struct to associate with script/function/method execution |
delta | Whether to set timing in seconds(true) or steps (false) |
dur | Duration of time before script is called |
script | Script, function, or method to execute when timer expires |
[arg0, ...] | (Optional) Arguments to pass to script |
Returns: tween id Example
|
Allows for the chaining of script scheduling. Returns a tween id handle so it can be manipulated like other regular tweens. This means you can call functions like TweenPause(), TweenResume(), or even TweenAddCallback() on returned handles. TweenMoreScript(tween, target, delta, dur, script, [arg0, ...]) |
tween | Tween id |
target | Instance or struct to associate with script/function/method execution |
delta | Whether to set timing in seconds(true) or steps (false) |
dur | Duration of time before script is called |
script | Script, function, or method to execute when timer expires |
[arg0, ...] | (Optional) Arguments to pass to script |
Returns: tween id Example
|
Eases the position of an instance over a set duration of time. TweenEasyMove(x1, y1, x2, y2, delay, duration, ease, [mode=0]) |
x1 | Starting x value |
y1 | Starting y value |
x2 | Destination x value |
y2 | Destination y value |
delay | Duration of time to delay start of tween |
duration | Duration of time to ease position from start to destination |
ease | Easing function (EaseInOutSine), easing name ("InOutSine"), or animation curve id/channel |
[mode=0] | (Optional) Play mode number/macro (0-4, TWEEN_MODE_*) or string ("once", "patrol", etc) |
Returns: tween id Example
|
Eases the image angle of an instance over a set duration of time. TweenEasyRotate(angle1, angle2, delay, duration, ease, [mode=0]) |
angle1 | Starting image angle value |
angle2 | Destination image angle value |
delay | Duration of time to delay start of tween |
duration | Duration of time to ease image angle from start to destination |
ease | Easing function (EaseInOutSine), easing name ("InOutSine"), or animation curve id/channel |
[mode=0] | (Optional) Play mode number/macro (0-4, TWEEN_MODE_*) or string ("once", "patrol", etc) |
Returns: tween id Example
|
Eases the image x/y scale of an instance over a set duration of time. TweenEasyScale(xscale1, yscale1, xscale2, yscale2, delay, duration, ease, [mode=0]) |
x1 | Starting xscale value |
y1 | Starting yscale value |
x2 | Destination xscale value |
y2 | Destination yscale value |
delay | Duration of time to delay start of tween |
duration | Duration of time to ease image scale from start to destination |
ease | Easing function (EaseInOutSine), easing name ("InOutSine"), or animation curve id/channel |
[mode=0] | (Optional) Play mode number/macro (0-4, TWEEN_MODE_*) or string ("once", "patrol", etc) |
Returns: tween id Example
|
Eases the direction of an instance over a set duration of time. TweenEasyTurn(dir1, dir2, delay, duration, ease, [mode=0]) |
dir1 | Starting direction value |
dir2 | Destination direction value |
delay | Duration of time to delay start of tween |
duration | Duration of time to ease direction from start to destination |
ease | Easing function (EaseInOutSine), easing name ("InOutSine"), or animation curve id/channel |
[mode=0] | (Optional) Play mode number/macro (0-4, TWEEN_MODE_*) or string ("once", "patrol", etc) |
Returns: tween id Example
|
Eases the image alpha of an instance over a set duration of time. TweenEasyFade(alpha1, alpha2, delay, duration, ease, [mode=0]) |
alpha1 | Starting alpha value |
alpha2 | Destination alpha value |
delay | Duration of time to delay start of tween |
duration | Duration of time to ease image alpha from start to destination |
ease | Easing function (EaseInOutSine), easing name ("InOutSine"), or animation curve id/channel |
[mode=0] | (Optional) Play mode number/macro (0-4, TWEEN_MODE_*) or string ("once", "patrol", etc) |
Returns: tween id Example
|
Eases the image blend colour of an instance over a set duration of time. TweenEasyBlend(col1, col2, delay, duration, ease, [mode=0]) |
col1 | Starting image blend colour |
col2 | Destination image blend colour |
delay | Duration of time to delay start of tween |
duration | Duration of time to ease image blend from start to destination |
ease | Easing function (EaseInOutSine), easing name ("InOutSine"), or animation curve id/channel |
[mode=0] | (Optional) Play mode number/macro (0-4, TWEEN_MODE_*) or string ("once", "patrol", etc) |
Returns: tween id Example
|
Eases the image index of an instance over a set duration of time. TweenEasyImage(index1, index2, delay, duration, ease, [mode=0]) |
index1 | Starting image index value |
index2 | Destination image index value |
delay | Duration of time to delay start of tween |
duration | Duration of time to ease image index from start to destination |
ease | Easing function (EaseInOutSine), easing name ("InOutSine"), or animation curve id/channel |
[mode=0] | (Optional) Play mode number/macro (0-4, TWEEN_MODE_*) or string ("once", "patrol", etc) |
Returns: tween id Example
|
Eases the image index of an instance over a set duration of time. TweenEasySpeed(speed1, speed2, delay, duration, ease, [mode=0]) |
speed1 | Starting image index value |
speed2 | Destination image index value |
delay | Duration of time to delay start of tween |
duration | Duration of time to ease speed from start to destination |
ease | Easing function (EaseInOutSine), easing name ("InOutSine"), or animation curve id/channel |
[mode=0] | (Optional) Play mode number/macro (0-4, TWEEN_MODE_*) or string ("once", "patrol", etc) |
Returns: tween id Example
|
Eases the image index of an instance over a set duration of time. TweenEasySpeedHV(hspeed1, vspeed1, hspeed2, vspeed2, delay, duration, ease, [mode=0]) |
hspeed1 | Starting hspeed value |
vspeed1 | Starting vspeed value |
hspeed2 | Destination hspeed value |
vspeed2 | Destination vspeed value |
delay | Duration of time to delay start of tween |
duration | Duration of time to ease h/vspeed from start to destination |
ease | Easing function (EaseInOutSine), easing name ("InOutSine"), or animation curve id/channel |
[mode=0] | (Optional) Play mode number/macro (0-4, TWEEN_MODE_*) or string ("once", "patrol", etc) |
Returns: tween id Example
|
Eases position using a path resource over a set duration of time. TweenEasyPath(path, absolute, delay, duration, ease, [mode=0]) |
path | Path resource id |
absolute | Use path's absolute position? |
delay | Duration of time to delay start of tween |
duration | Duration of time to ease position from start to destination |
ease | Easing function (EaseInOutSine), easing name ("InOutSine"), or animation curve id/channel |
[mode=0] | (Optional) Play mode number/macro (0-4, TWEEN_MODE_*) or string ("once", "patrol", etc) |
Returns: tween id Example
|
Toggles between STEP (false) and SECONDS (true) timing for all new "Easy Tweens". If no value is given, TweenEasyUseDelta() will return the current system value. The default for Easy Tweens is STEP timing. TweenEasyUseDelta([use_seconds]) |
[use_seconds] | Use seconds? |
Returns: na Example
|
Pauses the indicated tween. This function supports Tween Selection. TweenPause(tween[s]) |
tween[s] | Tween id or Tween Selection |
Returns: na Example
|
Resumes the indicated tween. This function supports Tween Selection. TweenResume(tween[s]) |
tween[s] | Tween id or Tween Selection |
Returns: na Example
|
Stops the indicated tween. This function supports Tween Selection. TweenStop(tween[s]) |
tween[s] | Tween id or Tween Selection |
Returns: na Example
|
Reverses the indicated tween. This function supports Tween Selection. TweenReverse(tween[s]) |
tween[s] | Tween id or Tween Selection |
Returns: na Example
|
Immediately finishes the indicated tween. It also asks if you want to call any "finish" event callbacks. This function supports Tween Selection. TweenFinish(tween[s], [call_event=true], [finish_delay=true], [call_delay_event=true]) |
tween[s] | Tween id or Tween Selection |
[call_event=true] | Execute FINISH event callbacks? |
[finish_delay=true] | Finish if tween is still delayed? callbacks? |
[call_delay_event=true] | Execute DELAY FINISHED event callbacks? |
Returns: na Example
|
Immediately finishes a tween's delay and starts playing the tween. It also asks if you want to call any associated "delay finish" event callbacks. This function supports Tween Selection. TweenFinishDelay(tween[s], [call_event=true]) |
tween[s] | Tween id[s] |
[call_event=true] | Execute FINISH DELAY EVENT callbacks? |
Returns: na Example
|
Manually destroys tween[s]. This function supports Tween Selection. TweenDestroy(tween[s]) |
tween[s] | Tween id or Tween Selection |
Returns: na Example
|
Sets whether or not a tween should auto-destroy when it is finished playing. When using TweenFire(), this defaults to true. When using TweenCreate(), this defaults to false. This function supports Tween Selection. TweenDestroyWhenDone(tween[s], [destroy=true], [kill_target=false]) |
tween[s] | Tween id or Tween Selection |
[destroy=true] | Destroy tween when finished? |
[kill_target=false] | Destroy the associated target instance when finished? |
Returns: na Example
|
Returns true if the indicated tween exists. TweenExists(tween) |
tween | Tween id |
Returns: bool Example
|
Returns true if the tween is playing or actively processing a delay. This is similar to TweenIsPlaying(), except that it also returns true if the tween is delayed. TweenIsActive([tween[s]]) |
[tween[s]] | Tween id or Tween Selection |
Returns: bool Example
|
Returns true if the tween is playing. This is similar to TweenIsActive(), except that it will return false if the tween is delayed. TweenIsPlaying([tween[s]]) |
[tween[s]] | Tween id or Tween Selection |
Returns: bool Example
|
Returns true if the tween is paused. TweenIsPaused([tween[s]]) |
tween | Tween id or Tween Selection |
Returns: bool Example
|
Returns true if the tween is resting. This is for tweens with play modes which continue ("bounce", "patrol", "loop", "repeat"). Tweens with these modes can be told to rest for a duration of time before continuing. TweenIsResting([tween[s]]) |
tween | Tween id or Tween Selection |
Returns: bool Example
|
Returns true if a tween JUST started to play. This will return true only for the first step/frame. TweenJustStarted(tween) |
tween | Tween id |
Returns: bool Example
|
Returns true if a tween JUST finished playing. This will return true only for the first step/frame. TweenJustFinished(tween) |
tween | Tween id |
Returns: bool Example
|
Returns true if a tween was JUST paused. This will return true only for the first step/frame. TweenJustPaused(tween) |
tween | Tween id |
Returns: bool Example
|
Returns true if a tween was JUST resumed. This will return true only for the first step/frame. TweenJustResumed(tween) |
tween | Tween id |
Returns: bool Example
|
Returns true if a tween was JUST stopped. This will return true only for the first step/frame. TweenJustStopped(tween) |
tween | Tween id |
Returns: bool Example
|
Returns true if a tween JUST rested. This will return true only for the first step/frame. TweenJustRested(tween) |
tween | Tween id |
Returns: bool Example
|
Returns true if a tween JUST continued. This will return true only for the first step/frame. TweenJustContinued(tween) |
tween | Tween id |
Returns: bool Example
|
Accesses specific data for a given tween by using a specified data label. If a tween has multiple properties, then "start", "destination", and "property" will return an array of values in the original order provided. Shorthand "tags" are also supported. (e.g. "~") Supported Data Labels: "group" -- Group which tween belongs to "time" -- Current time of tween in steps or seconds "time_amount" -- Sets the tween's time by a relative amount between 0.0 and 1.0 "time_scale" -- How fast a tween updates : Default = 1.0 "duration" -- How long a tween takes to fully animate in steps or seconds "ease" -- The easing algorithm used by the tween "mode" -- The play mode used by the tween (ONCE, BOUNCE, PATROL, LOOP) "target" -- The instance or struct associated with tween and properties "delta" -- Toggle timing between seconds(true) and steps(false) "delay" -- Current timer of active delay "delay_start" -- The starting duration for a delay timer "start" -- Start value of the property or properties "destination" -- Destination value of the property or properties "rawstart" -- The raw value supplied to start "rawdest" -- The raw value supplied to destination "property" -- Property or properties affected by the tween "caller" -- The instance or struct environment which called the tween functionTweenGet(tween, dataLabel) |
tween | Tween id |
dataLabel | Specified data label |
Returns: real/string Example
|
Changes the specific data for a given tween by using a specified data label. Shorthand "tags" are also supported. (e.g. "~ioSine", "#patrol") For tweens with multiple properties, "start", "destination", and "property" can be supplied additional arguments by passing an array. Using the keyword [undefined] in the array will leave a value unchanged. Supported Data Labels: "group" -- Group which tween belongs to "time" -- Current time of tween in steps or seconds "time_amount" -- Sets the tween's time by a relative amount between 0.0 and 1.0 "time_scale" -- How fast a tween updates : Default = 1.0 "duration" -- How long a tween takes to fully animate in steps or seconds "ease" -- The easing algorithm used by the tween "mode" -- The play mode used by the tween (ONCE, BOUNCE, PATROL, LOOP) "target" -- Target instance associated with tween "delta" -- Toggle timing between seconds(true) and steps(false) "delay" -- Current timer of active delay "delay_start" -- The starting duration for a delay timer "start" -- Start value of the property or properties "destination" -- Destination value of the property or properties "property" -- Property or properties affected by the tween e.g. tween = TweenFire(self, EaseLinear, 0, true, 0, 1, "x", 0, 100); TweenSet(tween, "duration", 2.5); TweenSet(tween[s], dataLabel, value, [...]) |
tween[s] | Tween id or Tween Selection |
data_label | Specified data label |
value | New data value |
[...] | (optional) Additional data_label/value pairs |
Returns: na Example
|
Allows a previously created tween to be defined or redefined. TweenDefine(tween, ease, mode, delta, delay, dur, prop, start, dest, [...]) |
tween | Tween id |
ease | Ease algorithm script (e.g. EaseInOutQuad) |
mode | Play mode constant (0-4) (TWEEN_MODE_****) |
delta | Whether to set timing in seconds(true) or steps (false) |
delay | Amount of time to delay start of tween in seconds or steps |
dur | Duration of time to ease property from start to destination |
prop | Property variable string (e.g. "x", "direction", "speed") |
start | Starting value of eased property |
dest | Destination value of eased property |
[...] | Additional properties (in order: prop,start,dest) |
Returns: tween id Example
|
Gets the default base values for newly created tweens. Supported data labels: "group" "delta" "scale" "ease" "mode" "duration" "rest" "amount" "continue_count" TweenDefaultGet(data_label) |
data_label | string name for data type (e.g. "group") |
Returns: any Example
|
Sets the default base values for newly created tweens. Supported data labels: "group" "delta" "scale" "ease" "mode" "duration" "rest" "amount" "continue_count" TweenDefaultSet(data_label, value) |
data_label | string name for data type (e.g. "group") |
value | value to assign as default value |
Returns: undefined Example
|
Returns the group-wide timescale for a specified tween group. This does not affect per-tween time scales. Each tween's timescale will be multiplied by the group timescale and system timescale TweenGroupGetTimeScale(group) |
group | specific tween group |
Returns: real Example
|
Returns the group-wide timescale for a specified tween group. This does not affect per-tween time scales. Each tween's timescale will be multiplied by the group timescale and system timescale TweenGroupSetTimeScale(group, scale) |
group | specific tween group |
scale | timescale to assign to group |
Returns: real Example
|
Works simliar to GameMaker's lerp() function, except that it takes an extra parameter for the ease type. Ease(value1, value2, amount, ease) |
value1 | start value |
value2 | end value |
amount | amount to interpolate value (0-1) |
ease | ease algorithm script |
Returns: real Example
|
Steps a tween forward or backward by a given amount. The direction can be a decimal (floating point) value. Using 1.0 or -1.0 will step a tween 1 step in the indicated direction. Lesser values, such as 0.5, will step the tween half a step foward. Greater values, such as 2.0, will step a tween 2 steps forward.TweenStep(tween[s], amount) |
tween[s] | Tween id or Tween Selection |
amount | Amount to step tween[s] |
Returns: real Example
|
Returns a calculated value using a tween's current state. A real number is returned directly if only one property is tweened. An array of real numbers is returned if multiple properties are tweened, in the order they were originally supplied to the tween. TweenCalc(tween, [amount]) |
tween | Tween ID |
[amount] | (optional) amount between 0-1 or explicit [time] passed as array |
Returns: real | array Example
|
Assigns usable "string" name to a ease function or animation curve. Typically, you should only define at the start of application. EaseToString(name, ease|curve|channel, [channel]) |
name | name to associate with ease type |
ease|curve|channel | ease function/method, curve id, or curve channel |
[channel] | optional curve channel (if curve id used) |
Returns: real Example
|
Whether or not "Tweens*()" scripts should return tween[s] associated with deactivated targets. Default = false TweensIncludeDeactivated(target) |
include_deactivated? | Include tweens belonging to deactivated targets/instances? |
Returns: na Example
|
Passes an array and its indexed value to be tweened. TPArray(array, index) |
array | Valid array |
index | The array index |
Returns: advanced property Example
|
Passes a list and its indexed value to be tweened. TPList(list, index) |
list | Valid ds_list id |
index | The index of the list to tween |
Returns: list property Example
|
Passes a map and its key value to be tweened. TPMap(map, key) |
map | Valid map id |
key | The key of the map to tween |
Returns: map property Example
|
Passes a grid and its indexed value to be tweened. TPGrid(grid, x, y) |
grid | Valid grid id |
x | The x index for grid |
y | The y index for grid |
Returns: grid property Example
|
Rounds up the value of the eased property TPCeil(property) |
property | string variable name to ease |
Returns: array Example
|
Rounds down the value of the eased property TPFloor(property) |
property | string variable name to ease |
Returns: array Example
|
Rounds the value of the eased property TPRound(property) |
property | string variable name to ease |
Returns: array Example
|
Randomly shakes the value of the eased property by a given amount. TPShake(property, amount) |
property | string variable name to ease |
amount | amount to "randomly" shake eased value |
Returns: array Example
|
Snaps the value of the eased property by a given amount. TPSnap(property, snap) |
property | string variable name to ease |
snap | the value for snapping eased property values |
Returns: array Example
|
Allows user events to be used as tween property setters/getters. Inside of the specified user event: TWEEN_USER_VALUE contains the eased value. TWEEN_USER_DATA contains any custom data provided. NOTE: Passing a single custom value will directly pass the value. However, passing two or more values will pass them as an array. TWEEN_USER_GET provides a way to create "getters" for user events. See the example below for an example of how to use it. TPUser(user_event, [arg0], ...) |
user_event | An object's user event |
arg0... | (optional) Custom data to be passed to user event |
Returns: advanced property Example
|
Allows for tweening a property belonging to another instance/struct target, different from the tween's own target. TPTarget(target, name) |
target | instance or struct |
name | string variable name to ease |
Returns: array Example
|
Allows a property value to ease properly between 2 colours. TPCol(name) |
name | string variable name to ease |
Returns: array Example
|
Allows position to be eased by using a path resource. Note: The start and destination values must be 0 and 1, respectively, to use the whole path. TPPath(path, absolute) |
path | path index |
absolute | use absolute path start position? |
Returns: array Example
|
Allows position to be eased by using a path resource, starting at a given position. Note: The start and destination values must be 0 and 1, respectively, to use the whole path. TPPathExt(path, x, y,) |
path | path index |
x | starting x position |
y | starting y position |
Returns: array Example
|
Event callbacks allow you to execute scripts/functions/methods or user events when a specified tween event occurs. The following tween event macros are: TWEEN_EV_PLAY -- When tween starts to play TWEEN_EV_FINISH -- When tween is finished playing TWEEN_EV_CONTINUE -- When tween continues with TWEEN_MODE_BOUNCE, TWEEN_MODE_PATROL, TWEEN_MODE_REPEAT TWEEN_EV_STOP -- When tween is manually stopped TWEEN_EV_PAUSE -- When tween is paused TWEEN_EV_RESUME -- When tween is resumed TWEEN_EV_REVERSE -- When tween is reversed There are also events for delayed tweens: TWEEN_EV_FINISH_DELAY -- When a tween's delay expires TWEEN_EV_STOP_DELAY -- When a delayed tween is stopped TWEEN_EV_PAUSE_DELAY -- When a delayed tween is paused TWEEN_EV_RESUME_DELAY -- When a paused delayed tween is resumed Events also support string names as an alternative to macros: TWEEN_EV_PLAY "play" "played" TWEEN_EV_FINISH "finish" "finished" TWEEN_EV_CONTINUE "continue" "continued" TWEEN_EV_STOP "stop" "stopped" TWEEN_EV_PAUSE "pause" "paused" TWEEN_EV_RESUME "resume" "resumed" TWEEN_EV_REVERSE "reverse" "reversed" TWEEN_EV_FINISH_DELAY "finish_delay" "finished_delay" TWEEN_EV_STOP_DELAY "stop_delay" "stopped_delay" TWEEN_EV_PAUSE_DELAY "pause_delay" "paused_delay" TWEEN_EV_RESUME_DELAY "resume_delay" "resumed_delay"
Adds a script to be called for the specified event. TweenAddCallback(tween, event, target, script, [arg0, ...]) |
tween | Tween id |
event | Tween event macro (e.g. TWEEN_EV_FINISH) or string (e.g. "finish") |
target | Target instance or struct |
script | Script resource id (e.g. MyScript) |
[arg0...] | (optional) Arguments to pass to script |
Returns: callback id Example
|
Adds a user event to be called for the specified event. TweenAddCallbackUser(tween, event, target, user_event) |
tween | Tween id |
event | Tween event macro (e.g. TWEEN_EV_FINISH) or string (e.g. "finish") |
target | Target instance or struct |
user_event | Object user event (e.g. 0-15) |
Returns: callback id Example
|
Invalidates (destroys) the given callback id. TweenCallbackInvalidate(callback) |
callback | Callback id |
Returns: na Example
|
Checks if a callback id is valid. TweenCallbackIsValid(callback) |
callback | Callback id |
Returns: bool Example
|
Allows callbacks to be temporarily disabled/enabled. TweenCallbackEnable(callback, enable) |
callback | Callback id |
enable | Enable the callback? |
Returns: na Example
|
Checks if callback is enabled. TweenCallbackIsEnabled(callback) |
callback | Callback id |
Returns: bool Example
|
Invalidates all callbacks associated with specified tween event. This function supports Tween Selection. TweenEventClear(tween[s], event) |
tween[s] | Tween id or Tween Selection |
event | Tween event macro (e.g. TWEEN_EV_FINISH) or string (e.g. "finish") |
Returns: na Example
|
Enables/disables specified tween event. This function supports Tween Selection. TweenEventEnable(tween[s], event) |
tween[s] | Tween id or Tween Selection |
event | Tween event macro (e.g. TWEEN_EV_FINISH) or string (e.g. "finish") |
enable? | Enable event? |
Returns: na Example
|
Checks if the specified callback event is enabled. TweenEventIsEnabled(tween, event) |
tween | Tween id |
event | Tween event macro (e.g. TWEEN_EV_FINISH) or string (e.g. "finish") |
Returns: bool Example
|
Accesses system data state by using a specified data label. SUPPORTED DATA LABELS: "enabled" // is system enabled? "time_scale" // global time scale "update_interval" // how often system should update in steps (default = 1) "min_delta_fps" // minimum frame rate before delta time lags behind (default=10) "auto_clean_count" // number of tweens to check for auto-cleaning each step (default=10) "delta_time" // tweening systems internal delta time "delta_time_scaled" // tweening systems scaled delta timeTweenSystemGet(dataLabel) |
dataLabel | Specified data label |
Returns: real Example
|
Updates system data state by using a specified data label. SUPPORTED DATA LABELS: "enabled" // set system enabled state "time_scale" // global time scale "update_interval" // how often system should update in steps (default = 1) "min_delta_fps" // minimum frame rate before delta time lags behind (default=10) "auto_clean_count" // number of tweens to check for auto-cleaning each step (default=10)TweenSystemSet(dataLabel, value) |
dataLabel | Specified data label |
value | New data value |
Returns: na Example
|
Clears tweens in inactive persistent room(s). TweenSystemClearRoom(room) |
room | Room index or [all] keyword for all rooms |
Returns: na Example
|
Overrides passive memory manager by immediately removing all destroyed tweens from the system. TweenSystemFlushDestroyed() |
Returns: na Example
|
[EXAMPLE FOR INSTANCE VARIABLE]It is also possible to use anonymous functions to assign properties with a single line:/// SETTER FUNCTION SET_my_var = function(value, target) { target.my_var = value; }/// GETTER FUNCTION GET_my_variable = function(target) { return target.my_var; }/// Apply property builder with functions above, only once at start of game TPFuncShared("my_var", SET_my_var, GET_my_var); [EXAMPLE FOR GLOBAL VALUE]/// SETTER SCRIPT SET_global_my_var = function(value) { global.my_var = value; }/// GETTER SCRIPT GET_global_my_var = function() { return global.my_var; }/// Apply property builder with functions/methods above, only once at start of game TPFuncShared("global.my_var", SET_global_my_var, GET_global_my_var);
// INSTANCE PROPERTY TPFuncShared("my_var", function(v,t){ t.my_var = v; }, function(t){ return t.my_var; });// GLOBAL PROPERTY TPFuncShared("global.my_var", function(v){ global.my_var = v; }, function(){ return global.my_var; });
Prepares a custom property setter/getter for a specified target instance or struct. This can be used to override shared properties. Ideally, call this from a CREATE event. TPFunc(target, "label", setter, getter) |
target | Instance or struct to associate with property |
label | String name to associate with property |
setter | Setter function to associate with property |
getter | Getter function to associate with property |
Returns: na Example
|
Prepares a property to be optimised for performance or to support advanced use cases. This function will be applied globaly to all instance/struct targets. Ideally, call TPFuncShared() functions at the start of your game. TPFuncShared("label", setter, getter) |
label | String name to associate with property |
setter | Setter function to associate with property |
getter | Getter function to associate with property |
Returns: na Example
|
Prepares a property to be normalized for values between 0-1. Look up the "image_blend" functions for an example. Ideally, call TPFuncSharedNormal() functions at the start of your game. TPFuncSharedNormal("label", setter, getter) |
label | String name to associate with property |
setter | Setter function to associate with property |
getter | Getter function to associate with property |
Returns: na Example
|
Allows a variable to be safely assigned a null tween which won't error if called with a tween function. This could change in the future, but its literal value is undefined. |
Example
|
Returns the system's default tween id for advanced needs. For most cases, please use TweenDefaultSet() and TweenDefaultGet() instead. |
Example
|
Allows a way for a tween to reference itself in an event callback or custom setter/getter property functions. |
Example
|
Allows a callback to reference itself from within tween events. |
Example
|
================== ANIMATION CURVES ================== GameMaker's built-in Animation Curves can be used in the place of easing algorithms: TweenFire(self, CurveIndex, 0, true, 0, 1, "x", 0, 100); Animation Curve channel's can also be used as an ease type: TweenFire(self, CurveChannel, 0, true, 0, 1, "x", 0, 100); For a curve to work well with TweenGMX, you typically want its first point to start at {h:0, v:0} and its last point to finish at {h:1, v:1}. However, like the included EaseHeartbeat animation curve, this isn't always the case! You can make use of animation curves for more advanced use cases. Please see the folder [TweenGMX] >> [Extras] >> [Animation Curves] for examples of how to make custom animation curves which work well with TweenGMX. Like easing functions, EaseToString() also supports animation curves. =============== TWEEN TO/FROM =============== Note: If coming from TweenGMS, TweenFireTo() and TweenFireFrom() are now obsolete. This convention can be used with: TweenFire TweenMore TweenCreate TweenPlay TweenDefine The ">" and "<" symbols can be used for easing a property TO or FROM its current value. For example, we can have 'x' ease from its current value to mouse_x... // EASE 'x' TO mouse_x TweenFire(self, EaseLinear, 0, true, 0, 1, "x>", mouse_x); As you might notice, no starting value is required for 'x', as its current value will be used. This would be similar to doing... TweenFire(self, EaseLinear, 0, true, 0, 1, "x", x, mouse_x); Likewise, we can have 'x' start FROM mouse_x and finish at its current position... // EASE 'x' FROM mouse_x to 'x' TweenFire(self, EaseLinear, 0, true, 0, 1, "x<", mouse_x); You can also mix To/From properties in the same function call... // EASE 'x' TO mouse_x AND EASE 'y' FROM mouse_y TO 'y' TweenFire(self, EaseLinear, 0, true, 0, 1, "x>", mouse_x, "y<", mouse_y); You can even mix To/From with the standard convention... TweenFire(self, EaseLinear, 0, true, 0, 1, "x>", mouse_x, "y<", mouse_y, "image_scale", 0, 1); Note that the symbol ":" can *optionally* be used for properties using the default start/destination convention to help with code clarity... // THESE BOTH DO THE SAME THING TweenFire(self, EaseLinear, 0, true, 0, 1, "image_scale", 0, 1); TweenFire(self, EaseLinear, 0, true, 0, 1, "image_scale:", 0, 1); ** ** Please be careful to supply the proper number or arguments when using the to/from convention! ** =================== "OFF-RAIL" TWEENS =================== An optional "off-rail" convention can be used for more user-specific control. This convention uses "-tags" which indicate which parameter we want to set. Here is a list of supported tags: (Associated shorthand tags [e.g. "?"] will be discussed later) "?" | "-target" "~" | "-ease" "#" | "-mode" "$" | "-duration" | "-dur" "^" | "-delta" "+" | "-delay" "|" | "-rest" ">" | "-continue_count" | "-count" | "-cc" "&" | "-group" "=" | "-time" ***Not to be confused with duration "%" | "-time_amount" | "-amount" "*" | "-time_scale" | "-scale" "!" | "-destroy Now, both of these tweens will do the same thing... // STANDARD CONVENTION TweenFire(self, EaseLinear, 0, 1, 0, 1, "x", 0, 100); // OFF-RAIL CONVENTION TweenFire("-target", self, "-ease", EaseLinear, "-mode", 0, "-delta", 1, "-delay", 0, "-dur", 1, "x", 0, 100); The off-rail mode might seem worse at first, but it gets better! First, we can remove the tags which have default values we don't need to set explicitly, such as "-target", "-mode", and "-delay"... // ASSUME TARGET=self, MODE=0, AND DELAY=0 TweenFire("-ease", EaseLinear, "-delta", 1, "-dur", 1, "x", 0, 100); That is looking cleaner. But we can do even better! We can actually set a global default for "delta" as well... // THIS ONLY NEEDS TO BE SET ONCE TweenDefaultSet("delta", true); // TWEEN WILL USE delta=true AS DEFAULT TweenFire("-ease", EaseLinear, "-dur", 1, "x", 0, 100); But, we can still go further! Shorthand symbols (e.g. "?") are also supported as tags. So, for example, we can use "~" instead of "-ease"... TweenFire("~", EaseLinear, "-dur", 1, "x", 0, 100); Likewise, we can replace "-dur" with "$" (time is money) TweenFire("~", EaseLinear, "$", 1, "x", 0, 100); Now, shorthand tags (except "?") support being condensed with explicit values. So, the example above could be shortened to this... TweenFire("~Linear", "$1", "x", 0, 100); And! Because EaseLinear is actually a tween default, it could even be shortened to just this... TweenFire("$1", "x", 0, 100); If we wanted to make this even shorter, we could use the TO/FROM ("x>") convention for our property... TweenFire("$1", "x>", 100); I hope you are getting the point! The off-rail mode allows you to set only what you need to. NOTE: Standard tween calls can also go "off-rails" AFTER the duration parameter is set. You are not even required to set variable properties first! Here are some examples: // FIRE STANDARD TWEEN BUT GO OFF-RAIL AT THE END TO SET TWEEN'S GROUP AND TIMESCALE TweenFire(self, EaseLinear, 0, true, 0, 1.0, "x", 0, 100, "-group", 10, "-scale", 0.5"); // GO OFF-RAIL RIGHT AFTER SETTING DURATION - SET x VARIABLE PROPERTY LAST TweenFire(self, EaseLinear, 0, true, 0, 1.0, "-group", 10, "-scale", 0.5, "x", 0, 100); Now, I will cover other supported conventions for shorthand tags. Note: upper/lower case and underscores DO NOT matter -- inQuad, IN_QUAD, and iNqUaD are all valid [EASE] Special Shorthand Tags *** The SINE algorithm supports additional default shorthand tags... "~i", "~o", "~io", "~in", "~out", "~inout" *** "~linear" "~InSine", "~iSine", "~in", "~i" "~OutSine", "~oSine", "~out", ~o"; "~InOutSine", "~ioSine", "~InOut", "~io" "~InQuad", "~iQuad" "~OutQuad", "~oQuad" "~InOutQuad", "~ioQuad" "~InCubic", "~iCubic" "~OutCubic", "~oCubic" "~InOutCubic", "~ioCubic" "~InElastic", "~iElastic" "~OutElastic", "~oElastic" "~InOutElastic", "~ioElastic" etc.... Note: These can also be used in regular "on-rail" tween calls, but remove the prefix "~" -> "ioElastic" e.g. // TWEEN USING EaseInOutSine ("io") TweenFire(self, "io", 0, true, 0, 1, "x>", 100); [MODE] Special Shorthand Tags "#0", "#o", "#once" "#1", "#b", "#bounce", "#2", "#p", "#patrol", "#3", "#l", "#loop", "#4", "#r", "#repeat Note: These can also be used in regular "on-rail" tween calls, but remove the prefix "#" -> "patrol" [ADDITONAL] Explicit Value Shorthand Tags Delta "^0" (STEP) "^1" (DELTA) Delay "+30" Duration "$30" Rest "|100" Continue Count ">5" Etc... NOTE: "?" does not support explicit values Now, it is also possible to add event callbacks directly within a tween call by using an "@event" tag. All supported callback tags start with "@" ... (letters in [] are optional) "@finish[ed]" / "@" -- ** Note that "@" is the same as "@finish" ** "@continue[d]" "@pause[d]" "@play[ed]" "@resume[d]" "@stop[ped]" "@rest[ed]" "@resting" "@reverse[d]" "@finish[ed]_delay" "@pause[d]_delay" "@resume[d]_delay" "@stop[ped]_delay" Let's continue with the previous example and extend it... // CALL FUNCTION 'ShowFireworks' WHEN TWEEN FINISHES // STANDARD WAY t = TweenFire("$1", "x>", 100); TweenAddCallback(t, TWEEN_EV_FINISH, self, ShowFireworks); // NEW WAY (OPTIONAL!) TweenFire("$1", "x>", 100, "@finish", ShowFireworks); If arguments need to be passed to the script, we can pass the callback as an array with additional arguments... // SHOW YELLOW FIREWORKS AT SPECIFIC LOCATION TweenFire("$1", "x>", 100, "@finish", [ShowFireworks, c_yellow, x, y]); // NOTE THAT "@" IS THE SAME AS "@finish" FOR EXTRA CONVENIENCE TweenFire("$1", "x>", 100, "@", [ShowFireworks, c_yellow, x, y]); If you want to set an explicit callback target, you can optionally pass a struct as the first array element, assigning a value to the 'target' field... // THIS WILL DO THE SAME THING AS ABOVE, EXCEPT THAT IT WILL USE 'obj_Player' AS THE CALLING ENVIRONMENT TweenFire("$1", "x>", 100, "@", [{target: obj_Player}, ShowFireworks, c_yellow, x, y]); Additionally, you can simply pass 'self' or 'other' as the first array element for assigning the callback target // USE 'other' AS THE CALLBACK TARGET TweenFire("$1", "x>", 100, "@", [other, ShowFireworks, c_yellow, x, y]); The keyword 'undefined' is also a valid callback target. This is useful for retaining a method's existing instance/struct calling environment as the callback target. // CALL obj_Enemy's 'meth_Explode' METHOD -- 'undefined' RETAINS ORIGINAL CALLING ENVIRONMENT FOR CALLBACK TARGET TweenFire("$1", "x>", 100, "@", [undefined, obj_Enemy.meth_Explode]); If a function ID is used, then 'undefined' will assign the tween's target as the callback target. Using 'undefined' in this case would be redundant, as callbacks already default to using the tween's target. // USE TWEEN'S TARGET AS CALLBACK TARGET FOR THE FUNCTION TweenFire("$1", "-target" obj_Enemy, "x>", 100, "@", [undefined, func_Explode]); NOTE: The keyword 'undefined' is also supported by TweenAddCallback() as a valid target. ================= TWEEN SELECTION ================= The keywords all, self, and other work as valid tween ids for various functions which support them. Functions which support multi-tween selection show 'tween{s}' as a parameter. So, for example, we can use self to pause all tweens associated with the current calling environment... // PAUSE ALL TWEENS ASSOCIATED WITH THE CALLING TARGET ENVIRONMENT TweenPause(self); You can likewise do this with the other keyword... // PAUSE ALL TWEENS ASSOCIATED WITH 'OTHER' ENVIRONMENT TweenPause(other); And! You can affect all tweens with the all keyword... // PAUSE ALL TWEENS TweenPause(all); For more advanced tween selection, structs can be used with specified properties... tween: -- ID HANDLE target: -- INSTANCE/OBJECT OR STRUCT REFERENCE group: -- ASSIGNED TWEEN GROUP VALUE list: -- ARRAY OR DS_LIST CONTAINING TWEEN IDS Here are some examples... // PAUSE TWEENS BELONGING TO GROUP 5 TweenPause({group: 5}); // PAUSE TWEENS BELONGING TO A SPECIFIC TARGET TweenPause({target: obj_Baddie}); // PAUSE TWEENS STORED IN AN ARRAY OR LIST TweenPause({list: array_ui_tweens}); TweenPause({list: list_baddie_tweens}); More than one struct property can be used for a single call... // PAUSE TWEENS ASSOCIATED WITH GROUP 5 AND TARGET 'self' AND TWEEN 'myTween' TweenPause({group: 5, target: self, tween: myTween}); And arrays can be used to pass more than one value to each struct property... // PAUSE TWEENS BELONGING TO GROUPS 5 AND 10, TARGETS self and other, AND VARIOUS TWEEN ID HANDLES TweenPause({group:[5,10], target:[self,other], tween:[tween1,tween2,tween3]}); =================== CONTINUE AND REST =================== There are 3 play modes which support "countinue counts": PATROL LOOP REPEAT When a tween reaches the start/destination points of the tween, continue counts determine if the tween will continue or finish. By default, countinue counts are infinite (-1). Setting a tween with a 'patrol' mode to a continue count of 1 will effectively make it the same as the 'bounce' mode. A tween's continue count can be set in these various ways: // #1 t = TweenFire(self, EaseLinear, "patrol", true, 0, 60, "x", 0, 100); TweenSet(t, "continue_count", 2); // #2 THE FOLLOWING ALL DO THE SAME THING TweenFire("$60", "#patrol", "-continue_count", 2, "x", 0, 100); TweenFire("$60", "#patrol", "-count", 2, "x", 0, 100); TweenFire("$60", "#patrol", "-cc", 2, "x", 0, 100) TweenFire("$60", "#patrol", ">", 2, "x", 0, 100); // Use ">" shorthand symbol TweenFire("$60", "#patrol", ">2", "x", 0, 100); // Use ">2" codensed shorthand It is also possible to set the "rest" duration for tweens which continue. This is the amount of time a tween will wait before continuing. This value can be set in the following ways... // #1 t = TweenFire(self, EaseLinear, "patrol", true, 0, 1, "x", 0, 100); TweenSet(t, "rest", 30); // #2 TweenFire("$60", "#patrol", "-rest", 30, "x", 0, 100); // THE FOLLOWING 2 EXAMPLES ARE THE SAME AS ABOVE BUT USE THE "|" SHORTHAND SYMBOL TweenFire("$60", "#patrol", "|", 30, "x", 0, 100); TweenFire("$60", "#patrol", "|30", "x", 0, 100); // Condensed shorthand The previous examples will cause the tween to rest for 30 steps before continuing. However, it also possible to have different rest durations for the start and destination points. This can be done by passing the rest parameter as an array... TweenFire("$60", "#patrol", "-rest", [30, 120], "x", 0, 100); This example above would cause the tween to rest for 30 steps after returning to the start position and have it rest for 120 steps after reaching the destination position. Now, if using the standard form of TweenFire() WITHOUT going "off-rails", you can still easily set these values by passing an array to the delay parameter. The first value is the main tween delay, and the second value the rest duration... // delay = 0 // rest = 30 TweenFire(self, EaseLinear, "patrol", false, [0, 30], 60, "x", 0, 100); To set the rest value for both the start and destination, a third argument can be passed to the array... // delay = 0 // start rest = 30 // destination rest = 120 TweenFire(self, EaseLinear, "patrol", false, [0, 30, 120], 60, "x", 0, 100); Optionally, you can also go "off-rail" after setting all required Tween*() parameters // GO OFF-RAIL AT THE END AND SET REST TweenFire(self, EaseLinear, "patrol", false, 0, 60, "x", 0, 100, "-rest", 30); ==================================== PROPERTY START/DESTINATION STRINGS ==================================== **Please be aware that this feature has strict limitations which will be explained further on** Start and destination values can now take string arguments which allow for more advanced uses. For example, the following can be done... TweenFire(self, "io", 0, false, 0, 60, "x>", "x+100"); The above example will move x to the *current* x position plus 100. Now, this isn't very useful in this case as we, instead, could directly do... TweenFire(self, "io", 0, false, 0, 60, "x>", x+100); However, if this tween adds a delay, then the string destination becomes useful. TweenFire(self, "io", 0, false, 30, 60, "x>", "x+100"); Now, after the delay finishes, the tween will check the *current* position of x and add 100 to that current value. So, if the target instance is moving around, this method can be used to adjust for a moving x value. There is also a shorthand symbol "@" for extra convenience. The "@" will represent which variable is being tweened. So, we could do this... TweenFire(self, "io", 0, false, 30, 60, "image_scale>", "@*2", "image_angle>", "@+360"); In the above example, the "@" symbol will be replaced with "image_scale" and "image_angle" respectively. Additionally, instance variables **from the current calling environment** and global variables can also be used in the string... value = 100; global.gValue = 200; TweenFire(self, "io", 0, false, 30, 60, "x>", "@+value; "y>", "@+gValue"); The above example will add 'value' and 'gvalue' to the respective properties. If TweenGMX does not detect an instance variable, it will automatically check for a global variable with the same name. You can still explicitly use global variables by supplying the "global." prefix. You can also reference values from other instances using an object id prefix... TweenFire(self, "io", 0, false, 30, 60, "x>", "obj_SomeDude.x + 100"); **NOTE: LOCAL VARIABLES ARE NOT SUPPORTED** // THIS WILL CAUSE AN ERROR! var _someVar = 100; TweenFire(self, "io", 0, false, 30, 60, "x>", "_someVar+100"); Now, the use of string values are quite limited. You can only have 2 values added, subtracted, multiplied, or divided. Some examples... "value+2" "@-value" "value*2" "@/value" In addition to stringed values, you can also use an array to set values relative to the current value of the given property variable. For example... TweenFire(self, "io", 0, false, 30, 60, "x>", [100], "y>", [-200]); The above example would move the 'x' right by 100 and 'y' up by 200. This could be the better option when wanting to use local temporary variables to set values. In addition to adjusting for value changes during a delay, this feature could also be useful when using TweenCreate() with TweenPlay(). ================= PROPERTY METHODS ================= ----- NOTE: This functionality is optional and advised for advanced users. You can often tween custom variables without having to set anything up. TPFuncShared() will affect all instances/structs with global defaults. * This is what built-in setters/getters use (e.g. "x", "direction", "image_angle") TPFunc() will prepare (and override) properties only for the given instance/struct. ----- Methods can be used as property 'setters' and 'getters'. We can use TPFunc() or TPFuncShared() to set them up. Here is an example of using TPFuncShared() for creating globally shared custom properties: // CREATE PROPERTY THAT ASSIGNS AND "SHAKES" THE X VALUE TPFuncShared("shake_x", function(value,target) { target.x = value + random_range(-5, 5); }, // SETTER function(target) { return target.x; } // GETTER ); // FIRE TWEEN USING CUSTOM PROPERTY "shake_x" TweenFire(obj_Player, "io", 0, true, 0, 1, "shake_x", 0, 100); The first setter method takes both a 'value' and 'target' argument and determines how eased values are assigned to the target. You can change the 'value' and 'target' parameter names to whatever you want... // THIS IS THE SAME AS EXAMPLE ABOVE TPFuncShared("shake_x", function(_v,_t) { _t.x = _v + random_range(-5, 5); }, // SETTER function(_t) { return _t.x; } // GETTER ); The second method supplied to TPFuncShared() is used as the 'getter' which receives a target and returns the value for that target's variable. Again, 'target' can be renamed to whatever you like. Likewise, we can use TPFunc() to set up custom properties for individual instances or structs. If a global property has already been set, then TPFunc will override it for the specified target: // CREATE CUSTOM PROPERTY SETTER WHICH ADDS A "shake" TO THE TWEENED 'x' VARIABLE TPFunc(self, "shake_x", function(value,target) // SETTER -- add random shake to x { target.x = value + random_range(-10, 10); }); // FIRE TWEEN USING CUSTOM PROPERTY METHOD "shake_x" TweenFire(self, "io", 0, true, 0, 1, "shake_x", 0, 100); We can optionally supply our own getter as well by extending the example above... // CREATE CUSTOM METHOD PROPRETY SETTER WHICH ADDS A "shake" TO THE TWEENED VALUE TPFunc(self, "shake_x", function(value,target) { target.x = value + random_range(10) }, // SETTER function(target) { return target.x } // GETTER ); // THE ">" SYNTAX NOW USES THE CUSTOM 'GETTER' FUNCTION TweenFire(self, "io", 0, true, 0, 1, "shake_x>", 100); TPFunc can also be used directly inside of a tween function like so... // USE TPFunc DIRECTLY INSIDE TWEEN CALL TweenFire("$60", TPFunc(self,"myVar", function(v,t){ t.myVar = v; }), 0, 100); // ADDITIONAL CALLS CAN SIMPLY USE THE PREVIOUS "myVar" STRING INSTEAD OF CALLING TPFunc AGAIN // ** IN THE FOLLOWING EXAMPLE, '0' POINTS to the previously created tween above. TweenMore(0, "$60", "myVar", 0, 100); ============================ EASE AND DURATION SWAPPING ============================ For play modes which continue (bounce, patrol, loop, repeat), different EASE TYPES can be applied to the forward and backward motion of the tween by passing them as an array. The first index is the forward motion, and the second index is the backwards motion. eases = [EaseInSine, EaseLinear]; // forward=sine, backward=linear TweenFire(self, eases, "patrol", true, 0, 1, "x", 0, 100); Likewise, different DURATIONS can be applied for the forward and backward motion of a tween. durations = [1.0, 2.0]; // forward=1.0, backward=2.0 TweenFire(self, [EaseInSine, EaseLinear], "patrol", true, 0, durations, "x", 0, 100); And! Different REST periods can also be applied by passing an array to the DELAY parameter. The first index will hold the tween's initial delay. The second index will be the REST duration for when a tween continues from the start, and the third index is the rest duration for when the tween first continues. [(0)INITIAL DELAY] [(1)REST] |=======================| [(2)REST] delay_rests = [0, 1.0, 2.0]; // delay=0.0, start_rest=1.0, finish_rest=2.0 TweenFire(self, [EaseInSine, EaseLinear], "patrol", true, delay_rests, [5.0,8.0], "x", 0, 100); NOTE: If both directions use the same rest duration (or using TWEEN_MODE_BOUNCE), you only need to pass an array with 2 indexes. delay_rests = [0.0, 1.0]; // delay=0.0, rests=1.0 TweenFire(self, [EaseInSine, EaseLinear], "patrol", true, delay_rests, [5.0,8.0], "x", 0, 100); ================ LAZY TWEEN IDS ================ Previously created tweens can be addressed with the value '0'. For example... // FIRE A TWEEN BUT DON'T STORE ITS RETURNED ID TweenFire(self, "io", 0, true, 0, 1, "x>", 100); // USE '0' TO REFERENCE THE PREVIOUSLY CREATED TWEEN ID TweenAddCallback(0, TWEEN_EV_FINISH, SomeScript); It is even possible to use negative numbers to reference tweens created further back. But please be careful if you choose to use negative tween ids! Just because you can doesn't mean you should. // FIRE ANOTHER TWEEN TweenFire(self, "io", 0, true, 0, 1, "abc>", 100); // USING -1 WILL REFERENCE THE TWEEN CREATED JUST BEFORE THE ONE ABOVE TweenAddCallback(-1, TWEEN_EV_PLAY, AnotherScript); ======================= NEGATIVE TWEEN DELAYS ======================= This is bit of a hack at the moment which might not work in certain situations but it does remain as a cool nifty thing if you know it's there! Using a negative delay value will cause the tween properties to jump to the initial values of the tween, however, the tween will still be delayed by the absolute value of the delay. I hope that makes sense... let me show you! TweenFire(self, "io", 0, false, -30, 60, "x", x+100, x+200); In the above example, the 'x' variable will immediately jump to the start value right away. However, the tween will still be delayed for 30 steps before playing. This is in contrast to regular delays which will not automatically jump values to the start until the delay has first finished. WARNING: This is still buggy for some use cases but should be fine for basic needs. ================ STRUCT TARGETS ================ WARNING: Using structs as an explicit tween target can cause it to "stick around" longer than intended, as the garbage collector might be delayed in cleaning it up. Please manually destroy tweens with struct targets, using TweenDestroy(), if you need to make sure they are destroyed right away. This can be especially important when using tweens with callbacks, which could continue to be executed unexpectedly. Structs are directly supported as both properties AND targets. So, you can do the following... // CREATE A NEW STRUCT my_struct = {thing1:0, thing2:0}; // FIRE TWEEN, REFERENCING STRUCT FOR PROPERTIES TweenFire(self, "io", 0, true, 0, 1, "my_struct.thing1", 0, 100, "my_struct.thing2", 0, 200); But, we can also use a struct as an explicit tween target and directly supply it's given variables... // CREATE A NEW STRUCT my_struct = {thing1:0, thing2:0}; // FIRE TWEEN WITH STRUCT AS TARGET TweenFire(my_struct, "io", 0, true, 0, 1, "thing1>", 100, "thing2>", 200); But again, please be careful when using structs directly as targets. It is advised to manually destroy tweens with struct targets as GameMaker's garabage collector may be slow in clearing deleted structs from the system. This can cause TweenGMX to needlessly process tweens longer than desired. Note: If a tween is created within a struct, the struct's "self" will be used as the default target for off-rail tweens =================== GROUP TIME SCALES =================== Time scales can now be set per group by using the function TweenGroupSetTimeScale()... // SET GROUP 10 TO USE A TIME SCALE OF 0.5 TweenGroupSetTimeScale(10, 0.5); Please note that this is different from the example below... // SET THE TIME SCALE FOR EACH TWEEN WITHIN THE GROUP TweenSet({group: 10}, "time_scale", 0.5); The example above would change the time scale for EACH tween individually within the group and not affect the ACTUAL group scale as a whole. With this new addition, there are now 3 levels of time scales... GLOBAL GROUP PER-TWEEN GLOBAL, GROUP, and PER-TWEEN time scales can all be stacked together for combined effects... // SET SYSTEM SCALE TO x10.0 TweenSystemSet("time_scale", 10.0); // SET GROUP 2 SCALE TO x0.5 TweenGroupSetTimeScale(2, 0.5); // SET SPECIFIC TWEEN SCALE TO x.0.25 TweenSet(myTween, "time_scale", 0.25); The final output scale for 'myTween' above would be 1.25 ====================== CALCULATED DURATIONS ====================== This feature allows you to set the duration as an average rate of change. STEP and DELTA timing are both handled a bit differently: STEP: rate of change per step (on average) DELTA: rate of change per second (on average) This feature is enabled by passing a STRUCT as a tween's duration parameter. The struct can take various fields to determine how to calculate the total change for propreties. The calculated change is then divided by the amount passed to the given field to determine the final duration. 1) dist: calculates all property changes as a distance between points 2) avg: averages out all property changes 3) sum: sums all property changes 4) weight: uses each property change as a percentage of the total sum 5) min: uses only the property with the smallest change 6) max: uses only the property with the greatest change NOTE: When there is only one property tweened, all options will work exactly the same. Examples: // USE 'dist:' TO SET DURATION TweenFire(self, "io", 0, true, 0, {dist:50}, "x", 0, 100, "y", 0, 100); // 2.83 Seconds // USE 'avg:' TO SET DURATION TweenFire(self, "io", 0, true, 0, {avg:50}, "x", 0, 100, "y", 0, 100); // 2 Seconds // USE 'sum:' TO SET DURATION TweenFire(self, "io", 0, true, 0, {sum:50}, "x", 0, 100, "y", 0, 100); // 4 Seconds // USE 'weight:' TO SET DURATION TweenFire(self, "io", 0, true, 0, {avg:50}, "x", 0, 100, "y", 0, 100); // 2 Seconds // USE 'min:' TO SET DURATION TweenFire(self, "io", 0, true, 0, {min:50}, "x", 0, 50, "y", 0, 100); // 1 Second // USE 'max:' TO SET DURATION TweenFire(self, "io", 0, true, 0, {max:50}, "x", 0, 50, "y", 0, 100); // 2 Seconds TIP: A shorthand version for 'dist:' can be used by simply passing duration as an array. // USE 'dist:' TO SET DURATION BY PASSING ARRAY (e.g. [50]) TweenFire(self, "io", 0, true, 0, [50], "x", 0, 100, "y", 0, 100); The optional field 'use:' can also be set to limit the amount of properties to include in the calculation. // USE ONLY THE FIRST 2 PROPERTIES (x,y) FOR DURATION CALCULATION TweenFire(self, "io", 0, true, 0, {dist:50, use:2}, "x>", 100, "y>", 100, "image_angle", 0, 360); Calculated Durations can be useful for delayed tweens where you don't know the final start and/or destination values. // FIRE TWEEN WITH DELAY USING CALCULATED DURATION TwenFire("~io", "-delay", 100, "-duration", {dist:10}, "x>", mouse_x); ** Please note that calculated durations are not currently supported for ease/duration swapping ** // THIS CURRENTLY WON'T WORK TweenFire("-duration", [{avg:10},{avg:20}], "#patrol", "x", 0, 100);