Skip to main content

Tweens

The tween module handles the process of smoothly interpolating a value from one state to another over a specified duration.

For example, moving a sprite from x = 0 to x = 100 over 1 second, or fading a palette color from bright to dark.

Using the tween module for value interpolation allows for smoother or fancier results than manual linear calculations. The module handles timing, easing curves, and callbacks automatically.

How It Works

Use the Start Tween event to begin a tween. You specify the start value, end value, duration, and easing function. The tween runs in the background and updates the target value each frame until the duration is reached.

You can run multiple tweens simultaneously for different values — for example, tweening an actor's X and Y positions at the same time to create curved movement.

Managing Tweens

Easing Functions

Easing functions control the rate of change during the tween. A linear tween moves at constant speed, while easing functions create acceleration, deceleration, or bouncing effects.

  • In — Starts slow and accelerates.
  • Out — Starts fast and decelerates.
  • InOut — Starts slow, speeds up in the middle, and slows down at the end.

The available easing functions are:

  • quadIn
  • quadOut
  • quadInOut
  • cubeIn
  • cubeOut
  • cubeInOut
  • quartIn
  • quartOut
  • quartInOut
  • quintIn
  • quintOut
  • quintInOut
  • sineIn
  • sineOut
  • sineInOut
  • bounceIn
  • bounceOut
  • bounceInOut
  • circIn
  • circOut
  • circInOut
  • expoIn
  • expoOut
  • expoInOut
  • backIn
  • backOut
  • backInOut
  • elasticIn
  • elasticOut
  • elasticInOut

The best way to understand these is to check the Tweens example.

Tips

  • Use bounceOut for items landing or dropping into place.
  • Use backOut for UI elements that overshoot slightly before settling — it adds a polished feel.
  • Use sineInOut for gentle, natural-feeling movement.
  • Pause all tweens when the game is paused to prevent animations from continuing during menus.

See Also