What problem does it solve?
Tweens solve the problem of manually updating object properties every frame by providing a declarative way to interpolate values over time in Phaser 4.
Core Features & Use Cases
- Tween playback with Phaser’s TweenManager: Create and run tweens from a Scene using
this.tweens.add(...) for property animation without writing frame-by-frame logic.
- Advanced timing controls: Use duration, delay, ease, repeat, yoyo, and loop to choreograph complex motion patterns like oscillations or continuous looping.
- Multi-target and batch behaviors: Tween properties on one or many targets and stagger across arrays via
this.tweens.stagger(...) for effects like sequential reveals.
- Sequencing and orchestration: Chain tweens with
this.tweens.chain(...) to play animations in order, including chain-level callbacks and looping.
- Runtime control and callbacks: Pause/resume/seek/kill tweens and use callback hooks and event emitter patterns to react to lifecycle moments like
onStart and onComplete.
Quick Start
Create a tween in your Scene’s create() method to move an image from x=100 to x=600 over 2000ms using this.tweens.add({ targets: logo, x: 600, duration: 2000, ease: 'Power2' }).