A lightweight and powerful tween/animation system for GameMaker Studio 2 that uses Animation Curves for precise easing control. Provides a fluent API for creating smooth animations with minimal code.
Version: 2.1.0
- Fluent API - Chain methods for intuitive animation setup
- 11 Easing Types - LINEAR, EASE, CUBIC, QUART, EXPO, CIRC, BACK, ELASTIC, BOUNCE, FAST_SLOW, MID_SLOW
- Two Animation Types -
Once(single direction) andPatrol(round-trip) - Tag System - Group and control multiple animations together
- Time Scale Control - Global and per-animation timing adjustments
- Repeat System - Single, multiple, or infinite repetitions
- Reverse Playback - Reverse any animation direction on demand
- Reusable - Refresh and replay animations with new values
- Launch Chain - Queue animations to play sequentially or on specific repeats
- Works with Instances & Structs - Animate any variable on GameMaker instances or custom structs
- Frame-Independent - Uses GameMaker's Time Source system for consistent timing
- Clone or download this repository
- Import the '.yymps' file into your GameMaker Studio 2 project
// Create a simple animation
new SCurve("Ease")
.Target(obj_player)
.Once(1.5, "x", 500)
.Play();new SCurve("Cubic")
.Target(obj_ui)
.Once(0.8, "x", 300, "y", 200, "alpha", 0.5)
.Delay(0.3)
.OnFinish(function() { show_debug_message("Animation done!"); })
.Play();new SCurve("Ease")
.Target(button)
.Patrol(0.5, 0.5, 0.2, "scale_x", 1.1, "scale_y", 1.1)
.Repeat(-1) // Infinite repeats
.Play();Creates a new animation instance.
Parameters:
curve_name(String) - Name of the Animation Curve to use (e.g., "Ease", "Cubic", "Bounce")destroy_on_finish(Bool, optional) - Auto-destroy on finish (default: true)
var anim = new SCurve("Elastic");Sets the target instance or struct to animate.
new SCurve("Linear").Target(my_instance).Play();Configures a single-direction animation.
Parameters:
duration(Real) - Animation duration in secondsprop_name(String) - Variable name to animateend_value(Real/String) - Final value (supports relative syntax: "+100", "-50", "*2", "/2")
.Once(2.0, "x", 500, "y", "+300")Configures a round-trip animation.
Parameters:
duration_go(Real) - Forward phase duration in secondsduration_back(Real) - Return phase duration in secondsdelay(Real) - Wait time between phases in secondsprop_name(String) - Variable name to animateend_value(Real/String) - Value at end of forward phase
.Patrol(1.0, 1.0, 0.5, "x", 200)(Patrol only) Optionally set different return values for properties.
.Patrol(1.0, 1.0, 0, "y", 300)
.ReturningTo("y", 100) // Returns to 100 instead of starting positionSets initial delay before animation starts.
.Delay(0.5)Sets animation speed multiplier (1.0 = normal, 0.5 = half speed, 2.0 = double speed).
.TimeScale(0.8)Sets number of repetitions (-1 for infinite).
.Repeat(3) // Repeat 3 times
.Repeat(-1) // Infinite loopStarts the animation.
new SCurve("Ease").Target(obj).Once(1, "x", 100).Play();Pauses the animation.
anim.Pause();Resumes a paused animation.
anim.Resume();Stops the animation and resets timing.
anim.Stop();Recaptures initial property values from target. Useful for reusable animations.
anim.Refresh().Play();Cleans up animation resources.
anim.Destroy();(Once only) Reverses animation direction.
.Once(1.0, "x", 500)
.Reverse(true) // Animates from 500 back to original value
.Play();Executes when animation completes.
.OnFinish(function() { show_debug_message("Done!"); })Executes on each repeat completion (receives repeat count as parameter).
.OnRepeat(function(repeat_num) {
show_debug_message("Repeat " + string(repeat_num));
})Executes when initial delay completes.
.OnDelayFinish(function() { show_debug_message("Delay over"); })(Patrol only) Executes when forward phase completes.
.OnContinue(function() { show_debug_message("Reached target"); })(Patrol only) Executes when wait phase completes.
.OnWait(function() { show_debug_message("Starting return"); })Launches another animation at the end or on specific repeat.
var anim1 = new SCurve("Ease").Target(obj).Once(1, "x", 100);
var anim2 = new SCurve("Ease").Target(obj).Once(1, "y", 200);
anim1.Launch(anim2).Play(); // anim2 plays after anim1Controls auto-destruction behavior.
.DestroyOnFinish(false) // Keep animation instance after finishAssigns one or more tags for group control.
.Tag("ui", "menu")Checks if animation has a specific tag.
if (anim.HasTag("ui")) { /* ... */ }Returns true if animation is actively running.
if (anim.IsPlaying()) { show_debug_message("Running"); }Returns true if animation is paused.
if (anim.IsPaused()) { anim.Resume(); }Returns true if animation has stopped or completed.
if (anim.IsFinished()) { show_debug_message("Complete"); }Returns true if currently in delay phase.
if (anim.IsDelaying()) { /* ... */ }Returns true if animation is configured to play in reverse.
if (anim.IsReversed()) { /* ... */ }Returns animation type ("once" or "patrol").
var type = anim.GetType();(Patrol only) Returns current phase ("go", "wait", or "back").
if (anim.GetPatrolState() == "back") { /* ... */ }Returns normalized progress (0-1) of current phase.
var progress = anim.GetProgress();Returns number of completed repeats.
show_debug_message("Repeats done: " + string(anim.GetRepeatCount()));Pauses all active animations.
SCMaster.PauseAll();Resumes all paused animations.
SCMaster.ResumeAll();Sets global time scale for all animations.
SCMaster.SetGlobalTimeScale(0.5); // Slow-motion effectGets current global time scale.
var scale = SCMaster.GetGlobalTimeScale();Pauses all animations with a specific tag.
SCMaster.PauseTag("ui");Resumes animations with a specific tag.
SCMaster.ResumeTag("ui");Stops all animations with a specific tag.
SCMaster.StopTag("effects");Destroys all animations with a specific tag.
SCMaster.DestroyTag("temp");Sets time scale for animations with a specific tag.
SCMaster.SetTimeScaleByTag("ui", 1.5); // UI animations 50% fasterLaunches multiple animations with staggered delays.
SCMaster.StaggerLaunch(0.1, anim1, anim2, anim3); // 0.1s between eachSimple Curves includes 11 easing presets:
| Curve | Description |
|---|---|
LINEAR |
No easing, constant speed |
EASE |
Smooth ease in/out |
CUBIC |
Cubic ease in/out |
QUART |
Quartic ease in/out |
EXPO |
Exponential ease in/out |
CIRC |
Circular ease in/out |
BACK |
Back overshoot ease in/out |
ELASTIC |
Elastic bounce ease in/out |
BOUNCE |
Bouncy ease in/out |
FAST_SLOW |
Fast start, slow finish |
MID_SLOW |
Slow middle section |
new SCurve("Ease")
.Target(player)
.Once(1.0, "x", "+100", "y", "-50") // +100 pixels right, -50 down
.Play();var fade_out = new SCurve("Ease")
.Target(ui_element)
.Once(0.5, "alpha", 0);
var move = new SCurve("Cubic")
.Target(ui_element)
.Once(1.0, "x", 800);
fade_out.Launch(move).Play();new SCurve("Bounce")
.Target(obj_ball)
.Patrol(0.5, 0.5, 0, "y", "-100")
.Repeat(-1)
.OnContinue(function() { play_sound(snd_bounce); })
.Play();function create_pulse_animation(target) {
return new SCurve("Ease")
.Target(target)
.Patrol(0.2, 0.2, 0, "scale_x", 1.2, "scale_y", 1.2)
.Repeat(1)
.DestroyOnFinish(false);
}
// Reuse multiple times
var pulse = create_pulse_animation(button1);
pulse.Play();
// Later...
pulse.Refresh().Play();// Create multiple UI animations with tags
new SCurve("Ease").Target(btn1).Once(0.5, "alpha", 0).Tag("ui", "menu").Play();
new SCurve("Ease").Target(btn2).Once(0.5, "alpha", 0).Tag("ui", "menu").Play();
new SCurve("Ease").Target(btn3).Once(0.5, "alpha", 0).Tag("ui", "menu").Play();
// Control them all at once
SCMaster.PauseTag("menu"); // Pause all
SCMaster.ResumeTag("menu"); // Resume all
SCMaster.SetTimeScaleByTag("menu", 0.5); // Slow down menu animations// Pause game logic but keep animations at slower speed
SCMaster.SetGlobalTimeScale(0.3);
// Later, resume normal speed
SCMaster.SetGlobalTimeScale(1.0);- Simple Curves uses GameMaker's Time Source system for frame-independent timing
- Delta time is clamped to maintain smooth animation during frame drops
- Animations are automatically unregistered from the global manager when destroyed
- Use tags to efficiently manage groups of animations
- The library handles both instances and structs, adapting to the target type
Example usage is demonstrated in o_iamfade object:
- Creates a reversible animation on struct animation data
- Press spacebar to reverse/toggle animation direction
- Shows how to use callbacks and state queries
See LICENSE file for details.