Build games as easily as you play them — join the Phaser Beam waitlist for Early Access.
                
            
            class Example extends Phaser.Scene { preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v385'); this.load.atlas('cards', 'assets/atlas/cards.png', 'assets/atlas/cards.json'); } create () { this.createCards(); this.input.on('gameobjectover', (pointer, gameObject) => { gameObject.setTint(0xff0000); }); this.input.on('gameobjectout', (pointer, gameObject) => { gameObject.clearTint(); }); } createCards () { const frames = this.textures.get('cards').getFrameNames(); for (let i = 0; i < 64; i++) { const x = Phaser.Math.Between(0, 800); const y = Phaser.Math.Between(0, 600); const s = Phaser.Math.FloatBetween(0.4, 0.6); this.add.image(x, y, 'cards', Phaser.Math.RND.pick(frames)).setScale(s).setInteractive(); } } } const config = { type: Phaser.WEBGL, parent: 'phaser-example', width: 800, height: 600, scene: Example }; const game = new Phaser.Game(config);
class Example extends Phaser.Scene
{
    preload ()
    {
        this.load.setBaseURL('https://cdn.phaserfiles.com/v385');
        this.load.atlas('cards', 'assets/atlas/cards.png', 'assets/atlas/cards.json');
    }
    create ()
    {
        this.createCards();
        this.input.on('gameobjectover', (pointer, gameObject) =>
        {
            gameObject.setTint(0xff0000);
        });
        this.input.on('gameobjectout', (pointer, gameObject) =>
        {
            gameObject.clearTint();
        });
    }
    createCards ()
    {
        const frames = this.textures.get('cards').getFrameNames();
        for (let i = 0; i < 64; i++)
        {
            const x = Phaser.Math.Between(0, 800);
            const y = Phaser.Math.Between(0, 600);
            const s = Phaser.Math.FloatBetween(0.4, 0.6);
            this.add.image(x, y, 'cards', Phaser.Math.RND.pick(frames)).setScale(s).setInteractive();
        }
    }
}
const config = {
    type: Phaser.WEBGL,
    parent: 'phaser-example',
    width: 800,
    height: 600,
    scene: Example
};
const game = new Phaser.Game(config);