Multiple Image Rotation

Learn how to rotate multiple Image Game Objects independently by updating their rotation property at different speeds and directions within the update loop.

Multiple Image Rotation, running
1024 × 768
GitHub
class Example extends Phaser.Scene
{
    image2;
    image1;

    preload ()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v410');

        this.load.image('arrow', 'assets/sprites/arrow.png');

    }

    create ()
    {

        this.image1 = this.add.image(300, 300, 'arrow');
        this.image2 = this.add.image(400, 300, 'arrow');

        this.image1.name = 'bill';
        this.image2.name = 'ben';

    }

    update ()
    {

        this.image1.rotation += 0.01;
        this.image2.rotation -= 0.01;

    }
}

const config = {
    scale: { mode: Phaser.Scale.FIT },
    type: Phaser.CANVAS,
    parent: 'game-container',
    scene: Example
};

const game = new Phaser.Game(config);

More in Images16 examples