Bomb Sprite Class

An example of extending the Arcade Physics Sprite class to create a custom bomb object with randomized velocity, angular rotation, and world bounds collision.

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

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

        scene.add.existing(this);
        scene.physics.add.existing(this);

        this.setSize(18, 18);
        this.setBounce(1);
        this.setCollideWorldBounds(true);
        this.setVelocity(Phaser.Math.Between(-200, 200), 20);
        this.setAngularVelocity(Phaser.Math.Between(-10, 10) * 10)
    }
}

More in GameObjects13 examples