Jump to content

Does the particle system work in CANVAS?


Goshawk
 Share

Recommended Posts

After many hours of head scratching I've discovered that I cannot get particles to work in canvas. However, if I switch to game type AUTO, the particle emitter works.

Is there any way to get particles to work in canvas mode or is it not supported?

import 'phaser';

window.onload = function(){
    var config = {
        type: Phaser.CANVAS, // Particles won't render unless setting is Phaser.AUTO
        parent: 'phaser-example',
        width: 800,
        height: 600,
        scene: PlayGame
    };

    var game = new Phaser.Game(config);
}

class PlayGame extends Phaser.Scene{
    constructor(){
        super('PlayGame');
    }

    preload(){
        this.load.image('block', 'assets/block.png');
    }

    create(){
        this.block = this.add.particles('block');
        this.block.createEmitter({
            angle: { min: 240, max: 300 },
            speed: { min: 200, max: 300 },
            quantity: 6,
            lifespan: 2000,
            alpha: { start: 1, end: 0 },
            scale: { start: 1.5, end: 0.5 },
            on: false
        });

        this.input.on('pointerdown', function (pointer) {
            this.block.emitParticleAt(pointer.x, pointer.y);
        }, this);

    }
}

 

Link to comment
Share on other sites

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...