phaserjs/phaser/tweens
Claude Code and agent skill by phaserjs/phaser
- community
Checking that the SKILL.md file is still in the repository.
Phaser 4 tweens: this.tweens.add and this.add.tween, property values (relative, random, arrays, from/to, per-property config), easing names and easeParams, yoyo, hold, repeat and loop, stagger, Tween Chains (this.tweens.chain), number tweens (addCounter), callbacks and TWEEN events, persist, timeScale and the TweenManager. Use when moving, fading, scaling, pulsing, bobbing, shaking or bouncing an object, animating UI or a menu, counting a score up, or playing animations one after another. Corrects v3 habits: this.tweens.timeline() and createTimeline() are gone (use a chain, or this.add.timeline for mixed events); TweenChain.remove now removes the whole chain (removeTween removes one tween); tweens run on their own clock, so this.time.timeScale doesn't slow them. Triggers on: tween, tweens.add, ease, easing, yoyo, repeat, stagger, tween chain, addCounter, fade in, fade out, pulse, animate property.
Install
npx vskill@latest install phaserjs/phaser/tweensSKILL.md
The same SKILL.md was published earlier as phaserjs/phaser/tweens.
Tweens
Changing properties over time with the Scene's TweenManager (this.tweens): tween config, values, easing, chains, counters, callbacks and control.
Source: src/tweens/TweenManager.js, src/tweens/tween/ (Tween, TweenChain, BaseTween, TweenData), src/tweens/builders/ (how a config is read), src/tweens/typedefs/, src/math/easing/EaseMap.js. Related: time-and-timers (Timeline), curves-and-paths (PathFollower), animations.
Quick start
this.tweens.add(config)creates the tween, adds it and starts it.this.add.tween(config)is the same.targetsis one object, an array, or a function returning them. Any object with numeric properties works, not only Game Objects.- A tween destroys itself when it finishes. Keep a reference only to control it while it runs, or set
persist: true(see Control).
Property values
Any key that isn't a config option is a property to tween. Put them in props: { ... } if a name clashes with a config key.
- A function is called once per target and returns the end value:
x: (target, key, value, targetIndex, totalTargets, tween) => value + targetIndex * 50. - An array, such as
x: [ 100, 400, 200 ], tweens from the first value to the last and skips the middle ones, unless you setinterpolation: 'linear','bezier'or'catmull'(or a function), which passes through all of them. scaletweensscaleXandscaleY, unless the target has an ownscaleproperty, as a plain object might.- A property config object can also hold
getStart,getEndandgetActivecallbacks, with the same arguments as a function value. - Properties whose name starts with
_are never tweened.
Timing
| Key | Default | Meaning | |
|---|---|---|---|
duration | 1000 | ms for one play of each property. 0 or less becomes 0.01. | |
delay | 0 | ms before each property starts. A number, or a function (GetDelayCallback), such as this.tweens.stagger(...). | |
hold | 0 | ms to wait at the end value before a yoyo. | |
yoyo | false | Play back to the start value. | |
repeat | 0 | Extra plays of each property. repeat: 1 plays twice. -1 is forever. | |
repeatDelay | 0 | ms before each repeat. | |
flipX / flipY | false | Toggle the target's flip on each yoyo or repeat. | |
loop | 0 | Extra plays of the whole tween, after every property has finished. -1 is forever. | |
loopDelay | 0 | ms before each loop. | |
completeDelay | 0 | ms between finishing and onComplete. | |
paused | false | Create paused. Call tween.play() or resume() to start. | |
persist | false | Don't destroy the tween when it finishes. |
loop, loopDelay and completeDelay also take an array of numbers (one is picked at random), { randInt: [ min, max ] }, { randFloat: [ min, max ] }, or a function. They are picked once, when the tween is created.
repeat and the per-property keys can be set inside a property config, so properties can have different durations, delays and repeats.
Easing
- Names:
Linear,Quad,Cubic,Quart,Quint,Sine,Expo,Circ,Elastic,Back,Bounce,Stepped, each with.easeIn,.easeOutor.easeInOut. A bare name, such as'Bounce', is the Out version. Power0is Linear.Power1toPower4areQuad,Cubic,QuartandQuint.easeOut.- The short forms
'quad.in','sine.out'and'cubic.inout'work, in any case after the dot. - A name it doesn't recognise, such as
'easeInOutSine','Quadratic.Out'or'Sine.easeinout', silently becomes Linear. Check the spelling againstsrc/math/easing/EaseMap.js. easeParamsare passed after the progress:Elastictakes[ amplitude, period ](default 0.1, 0.1),Backtakes[ overshoot ](1.70158),Steppedtakes[ steps ].- A function works too:
ease: (v) => v * v, wherevgoes from 0 to 1. The built-ins are inPhaser.Math.Easing, such asPhaser.Math.Easing.Sine.InOut.
Stagger
this.tweens.stagger(value, config) returns a function to use as delay, or as a property value, for a tween with many targets.
StaggerConfig: start (offset added to each value), from ('first', 'center', 'last' or an index, default 0), ease, grid ([ width, height ]). It has no effect with one target.
Tween Chains
A chain plays tweens one after another.
this.add.tweenchain(config)is the same asthis.tweens.chain(config).- Chain-level keys:
targets,tweens,delay,loop(aliasrepeat),loopDelay(aliasrepeatDelay),completeDelay,paused,persist,callbackScopeand the tween-level callbacks.yoyo,holdandeasego on each tween. chain.add([ configs ])appends tweens, but they don't inherit the chain'stargets: give each onetargets, or it throws.chain.removeTween(tween)removes one tween from the chain. Since 4.3,chain.remove()removes the whole chain from the TweenManager, as it does for a Tween.- Chain callbacks receive only
(chain, ...params).
Number tweens
A tween with no target, for a value you read yourself, such as a score counting up.
It takes the usual timing and callback keys. The target is an object { value }.
Callbacks and events
Callbacks go in the config, or are set later with tween.setCallback('onComplete', fn, params). this is callbackScope, which defaults to the tween. Extra arguments go in on<Name>Params, such as onCompleteParams: [ 10 ].
| Callback | Event constant (string) | Arguments | |
|---|---|---|---|
onActive | TWEEN_ACTIVE ('active') | (tween, targets) | |
onStart | TWEEN_START ('start') | (tween, targets) | |
onLoop | TWEEN_LOOP ('loop') | (tween, targets) | |
onComplete | TWEEN_COMPLETE ('complete') | (tween, targets) | |
onStop, onPause, onResume | TWEEN_STOP, TWEEN_PAUSE, TWEEN_RESUME | (tween, targets) | |
onUpdate | TWEEN_UPDATE ('update') | callback (tween, target, key, current, previous) | |
onYoyo, onRepeat | TWEEN_YOYO, TWEEN_REPEAT | callback (tween, target, key, current, previous) |
onUpdate,onYoyoandonRepeatrun once per property per target. Their events are emitted with the arguments in a different order:(tween, key, target, current, previous).- The constants are in
Phaser.Tweens.Events:tween.on(Phaser.Tweens.Events.TWEEN_COMPLETE, fn). onStartfires after the delay.onCompletenever fires for a tween that repeats or loops forever.
Control
Read tween.progress (0 to 1, this play), totalProgress, elapsed, isPlaying(), isPaused(), hasTarget(obj).
TweenManager (this.tweens):
killTweensOf(target),getTweensOf(target),isTweening(target)(false when the tween is paused),killAll(),getTweens().pauseAll()/resumeAll(), orthis.tweens.paused.this.tweens.timeScale(orsetGlobalTimeScale(v)) scales every tween in the Scene. A tween's speed istween.timeScale * this.tweens.timeScale.create(config)makes a tween without starting it. Add it later withexisting(tween).
TypeScript (4.3)
easeisstring | Phaser.Types.Tweens.EaseFunction,delayacceptsPhaser.Types.Tweens.GetDelayCallback, andinterpolationacceptsPhaser.Types.Tweens.InterpolationFunction, so function arguments are typed.this.tweens.stagger()returns aGetDelayCallback.loop,loopDelayandcompleteDelayacceptnumber[]andPhaser.Types.Tweens.TweenRandomValue({ randInt }or{ randFloat }).
Gotchas
- Tweens have their own clock. The TweenManager measures time with
Date.now(), not the Scene Clock, sothis.time.timeScaleandthis.time.pauseddon't affect tweens. Usethis.tweens.timeScaleandthis.tweens.pauseAll(). Tweens stop while the Scene is paused or asleep. - Two tweens on the same property fight. Call
this.tweens.killTweensOf(target)before starting a new one, such as on hover in and out. - A finished tween is destroyed. Calling
play()orrestart()on it does nothing useful. Usepersist: true, or make a new tween. - Dispose of a persisted tween with `remove()` then `destroy()`.
destroy()alone leaves it in the TweenManager's list until the Scene shuts down. - `repeat` vs `loop`.
repeatreplays each property, straight after it ends.loopreplays the whole tween once every property has ended. - A destroyed target ends its tween. A tween stops updating a target whose
isDestroyedis true, so destroying a sprite mid-tween is safe. - All tweens in a Scene are destroyed when it shuts down, persisted or not.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/tweens/SKILL.md
Popularity
- Repository stars
- 39,633
- Repository forks
- 7,130
- 7-day trend score
- 53
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 17 May 2026, 6 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Grok Build (Cursor)
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/phaserjs/phaser/tweens)