Image Angle
Demonstrates how to set the rotation of an image in degrees using the angle property and setAngle method.
800 × 600
class Example extends Phaser.Scene
{
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('grid', 'assets/pics/debug-grid-1920x1920.png');
this.load.image('arrow', 'assets/sprites/arrow.png');
}
create ()
{
// Angle uses degrees instead of radians
for (let a = 0; a <= 360; a += 45)
{
const frame = this.add.image(40 + a * 2, 300, 'arrow').setAngle(a);
// You can also do: frame.angle = degrees;
}
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.WEBGL,
parent: 'game-container',
width: 800,
height: 600,
scene: Example
};
const game = new Phaser.Game(config);