A lightweight and flexible tweening library for Haxe.
- Framework-Agnostic
- Parallel and Sequential Tweens
- Customizable Easing Functions
- Powered by macros, no Haxe Reflect
Install the library via haxelib
:
haxelib install slide
Alternatively, clone the repository for the latest version:
git clone https://github.com/AndreiRudenko/slide
Animate an object property to a target value:
tweenManager.animateTo(myVec2, { x: 100 }, 1).start();
Animate multiple properties simultaneously:
tweenManager.animateTo(myVec2, { x: 100, y: 100 }, 1).start();
Apply easing with built-in or custom functions:
tweenManager.animateTo(myVec2, { x: 100 }, 1, Quad.easeOut).start();
tweenManager.animateTo(myVec2, { x: 100 }, 1, (t: Float) -> t * t).start();
Set up callbacks for various tweening events:
tweenManager.animateTo(myVec2, { x: 100 }, 1)
.onStart(() -> trace("start"))
.onStop(() -> trace("stop"))
.onReset(() -> trace("reset"))
.onPause(() -> trace("pause"))
.onResume(() -> trace("resume"))
.onRepeat(() -> trace("repeat"))
.onComplete(() -> trace("complete"))
.onUpdate(() -> trace("update"))
.start();
Chain animations sequentially:
tweenManager.sequence([
tweenManager.animateTo(myVec2, { x: 100 }, 1),
tweenManager.animateTo(myVec2, { y: 100 }, 1)
]).start();
Run multiple tweens concurrently:
tweenManager.parallel([
tweenManager.animateTo(myVec2, { x: 100 }, 1),
tweenManager.animateTo(myVec2, { y: 100 }, 1)
]).start();
- Tween from Target Value:
tweenManager.animateFrom(myVec2, { x: 0 }, 1).start();
- Tween Between Two Values:
tweenManager.animateFromTo(myVec2, { x: 0 }, { x: 100 }, 1).start();
- Tween by Adding Value to Property: Example: target value for x is current x + 100
tweenManager.animateBy(myVec2, { x: 100 }, 1).start();
- Tween Along a Set of Values:
tweenManager.animateAlong(myVec2, { x: [100, 200], y: [200, 300, 100, 500] }, 1).start();
You can add a delay as a simple timer:
tweenManager.delay(1, () -> trace("delay complete")).start();
Or add a delay to a sequence:
tweenManager.sequence([
tweenManager.animateTo(myVec2, { x: 100 }, 1),
tweenManager.delay(1),
tweenManager.animateTo(myVec2, { y: 100 }, 1)
]).start();
Pause, resume, stop, or reset tweens as needed:
var tween = tweenManager.animateTo(myVec2, { x: 100 }, 1);
tween.start();
tween.pause();
tween.resume();
tween.stop();
tween.reset();
- Infinite or Finite Loops: Less than 0 or no argument for infinite loop
tweenManager.animateTo(myVec2, { x: 100 }, 1).repeat(3).start();
- Yoyo Animation:
tweenManager.animateTo(myVec2, { x: 100 }, 1).yoyo().start();