Static Physics Sprite Class

Demonstrates creating a custom class that extends an Arcade Physics Sprite to define a static level exit with a specific texture frame and origin.

1024 × 768
GitHub
import SPRITE_KEYS from "../spriteKeys.js";

export class Exit extends Phaser.Physics.Arcade.Sprite
{
    constructor (scene, x, y)
    {
        super(scene, x, y, SPRITE_KEYS.FANTASY_TILES, 31);

        this.setOrigin(0, 0);
        scene.add.existing(this);
        scene.physics.add.existing(this, true);
    }
}

More in GameObjects13 examples