Random Line
Positions a group of sprites at random points along a specific geometric line.
800 × 600
class Example extends Phaser.Scene
{
constructor ()
{
super();
}
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('orb', 'assets/sprites/orb-blue.png');
}
create ()
{
const group = this.add.group({ key: 'orb', frameQuantity: 300 });
const line = new Phaser.Geom.Line(200, 200, 500, 400);
// Randomly position the sprites on the line
Phaser.Actions.RandomLine(group.getChildren(), line);
}
}
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);