Tween Circle Radius
Animates a group of sprites by tweening the radius of a geometric circle and updating their positions using the onUpdate callback.
800 × 600
class Example extends Phaser.Scene
{
constructor ()
{
super();
}
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('bg', 'assets/skies/space3.png');
this.load.image('star', 'assets/demoscene/ball-tlb.png');
}
create ()
{
this.add.image(400, 300, 'bg');
const stars = this.add.group({ key: 'star', repeat: 32 });
const circle = new Phaser.Geom.Circle(400, 300, 64);
Phaser.Actions.PlaceOnCircle(stars.getChildren(), circle);
this.tweens.add({
targets: circle,
radius: 228,
ease: 'Quintic.easeInOut',
duration: 1500,
yoyo: true,
repeat: -1,
onUpdate: function ()
{
Phaser.Actions.RotateAroundDistance(stars.getChildren(), { x: 400, y: 300 }, 0.02, circle.radius);
}
});
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.AUTO,
width: 800,
height: 600,
backgroundColor: '#2d2d2d',
parent: 'game-container',
scene: Example
};
const game = new Phaser.Game(config);