Rotate Around Distance
Demonstrates how to use the RotateAroundDistance action to rotate a group of game objects around a specific point while maintaining a fixed radius.
800 × 600
class Example extends Phaser.Scene
{
constructor ()
{
super();
}
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('ball', 'assets/sprites/shinyball.png');
}
create ()
{
this.group = this.add.group();
for (let i = 0; i < 32; i++)
{
this.group.create(i * 32, i * 2, 'ball');
}
}
update ()
{
Phaser.Actions.RotateAroundDistance(this.group.getChildren(), { x: 400, y: 300 }, 0.02, 200);
}
}
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);