Phaser 4 examples

Tweens

  • 85 examples
  • 2 folders

Folders 2

Examples 58

Card Flip Texture SwapDemonstrates how to create a card flipping effect by synchronizing a texture change with a scale tween.Change Texture FrameDemonstrates how to change a Game Object's texture frame as part of a tween, combined with other property changes like position and scale.Checkerboard Grid AnimationAligns a group of sprites into a grid and applies staggered scaling tweens to create a row-based wave animation effect.Checkerboard Grid RotationDemonstrates rotating a grid of sprites using tweens with random delays and dynamic rotation values calculated via getEnd and getStart callbacks.Counter TweenDemonstrates how to use a counter tween to interpolate between two numeric values and update a text display, including how to dynamically update the tween target value while it is still playing.Custom Ease FunctionDemonstrates how to provide a custom function to a tween's ease property to create unique motion curves.Double Tween ComparisonA side-by-side comparison of Phaser's built-in Tween Manager and the GSAP library, demonstrating identical movement using different animation engines.Dynamic End PropertyThis example demonstrates how to use functions to define tween target values, allowing the destination of a tween to update dynamically based on the current position of another object.Dynamic Tween PropertiesDemonstrates how to use getter functions to dynamically calculate the start and end values of a tween property during execution.ElasticityDemonstrates the use of elastic easing in a tween, including how to pass custom amplitude and period parameters to fine-tune the movement.Global Tween Time ScaleDemonstrates how to use the Tween Manager's global timeScale property to control the playback speed of all active tweens simultaneously.Grid Tween with Staggered Column DelaysArrange a group of sprites into a grid and apply scale tweens with staggered delays based on their column index to create a wave effect.Grid Tween with Staggered Column DelaysAligns a group of blocks into a grid and applies complex tweens with delays that reset at the end of every row, creating a synchronized column animation.Interpolation Methods for Array ValuesDemonstrates how to use an array of values for a tween property and apply different interpolation algorithms like Bezier and Catmull-Rom.Linear and Bounce TweenDemonstrates applying different easing functions, durations, and yoyo behaviors to the X and Y properties of a single sprite within one tween.Loop DelayDemonstrates how to add a delay between each iteration of a looping tween.Multiple Delayed PropertiesApply different durations, easing functions, and delays to multiple properties within a single tween, including the use of functional delays.Multiple Dynamic Tween PropertiesDemonstrates using dynamic functions for property values within a single tween to calculate start and end positions at runtime.Multiple PropertiesThis example demonstrates how to tween multiple properties of a single target simultaneously, with independent durations and easing functions for each property.Multiple Properties LoopDemonstrates how to animate multiple properties of a target simultaneously using different durations and easing functions, while looping the entire animation.Multiple Properties with Individual YoyoDemonstrates how to apply independent durations, easing functions, and yoyo effects to multiple properties within a single tween.Multiple TargetsDemonstrates how to apply a single tween to an array of multiple game objects simultaneously.Multiple Targets and Multiple PropertiesThis example shows how to tween multiple Game Objects simultaneously, with separate durations and easing functions for different properties like x and y.Number Counter TweenDemonstrates how to use addCounter to interpolate between two numeric values. This type of tween doesn't require a target object property and allows you to retrieve the current value, progress, and elapsed time manually.Number Counter Tween with YoyoDemonstrates how to use a counter tween to interpolate between two numeric values with a yoyo effect, accessing the current value and progress manually.On Complete CallbackDemonstrates how to use the onComplete callback and onCompleteParams to execute a function and pass custom data once a tween has finished.Pause and Resume a TweenDemonstrates how to toggle a tween's playback state between paused and playing using pointer input.Pause and Resume All TweensDemonstrates how to pause and resume every active tween in a scene simultaneously using the Tween Manager's global control methods.Paused TweenDemonstrates how to create a tween in a paused state and trigger its playback later using the play method.Relative Value Tween with RepeatingDemonstrates how to use relative string values like '-=64' to animate a property based on its current position, combined with yoyo and repeat settings.Relative Value TweensDemonstrates how to use string operators like += and -= to create tweens relative to an object's current property values.Remove TweenDemonstrates how to manually stop and remove an active tween from the Tween Manager using the tween's remove method.Seek To Point In TweenThis example demonstrates how to use the seek method to jump to a specific millisecond position within a running tween.Stagger DelayApply a staggered delay to a group of targets in a single tween, causing them to start their animation sequence at different intervals.Staggered Column TweensDemonstrates applying staggered scale and rotation animations to a grid of sprites using column-based delay calculations.Stop a TweenDemonstrates how to manually stop a running tween using the stop method, triggered by a pointer event.Tween Behavior with CPU LagDemonstrates how the tween system handles a significant main-thread block (CPU lag) while managing thousands of concurrent sprite tweens.Tween CallbacksDemonstrates how to use lifecycle event callbacks in a tween, including onStart, onComplete, onYoyo, onRepeat, onPause, and onResume.Tween Circle RadiusAnimates a group of sprites by tweening the radius of a geometric circle and updating their positions using the onUpdate callback.Tween Complete DelayThis example demonstrates how to use the completeDelay property to pause for a set duration after a tween finishes its movement before triggering the completion event.Tween DelayDemonstrates how to use the delay property to postpone the start of a tween for a specific duration.Tween Delay FunctionDemonstrates how to use a callback function to dynamically calculate the delay of a tween, allowing for randomized or logic-based start times.Tween Flip XUse the flipX property in a tween to automatically flip an image horizontally when it yoyos or repeats.Tween Flip YDemonstrates how to use the flipY property in a tween to automatically flip an image vertically when it yoyos or repeats.Tween From and To ValuesThis example shows how to explicitly define the starting and ending values of a property within a tween configuration.Tween Gauge AnimationSimulate a dial or gauge by tweening the rotation of a needle sprite using relative values, yoyo effects, and custom origins.Tween Lag RecoveryDemonstrates how the Phaser Tween Manager handles a sudden CPU block or lag spike during an active animation, showing how the tween positions synchronize once the thread is released.Tween Lag SmoothingDemonstrates how the tween system handles and recovers from significant CPU lag by simulating a long blocking process during tween playback.Tween LoopDemonstrates how to repeat a tween multiple times using the loop property and how to use the onLoop callback to track the current loop count.Tween Manager Garbage Collection PerformanceA stress test creating thousands of single-use tweens to demonstrate how the Tween Manager efficiently handles high volume and internal garbage collection.Tween On Start CallbackDemonstrates how to use the onStart event and onStartParams to execute a function and pass custom data when a tween begins playing.Tween On Yoyo CallbackDemonstrates how to use the onYoyo callback to trigger logic specifically when a tween finishes its forward motion and begins to reverse direction.Tween Performance Stress TestA performance test demonstrating the engine handling thousands of tweening Blitter objects simultaneously, adding 256 new items per frame while the pointer is held down.Tween Sprite AngleAnimate the rotation of a sprite between two specific angles using a repeating yoyo tween.Tween Sprite AngleDemonstrates how to rotate a sprite indefinitely by tweening its angle property with a relative value.Tween Stagger ShowcaseA demonstration of the different configurations available for stagger tweens, showcasing how to apply delays across a grid using various start points, ranges, and easing functions.Tween Text Size and ColorDemonstrates how to use a Tween Counter to animate the font size and color of a Text object via the onUpdate callback.Tween Texture ChangeDemonstrates how to swap the texture of an image using a repeating tween and trigger particle effects during the swap using the onRepeat callback.