Mouse Down Event
Detect a pointer down event and spawn a sprite at the pointer coordinates.
1024 × 768
class Example extends Phaser.Scene
{
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.image('logo', 'assets/sprites/phaser.png');
}
create ()
{
this.input.on('pointerdown', function (pointer)
{
console.log('down');
this.add.image(pointer.x, pointer.y, 'logo');
}, this);
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.AUTO,
parent: 'game-container',
scene: Example
};
const game = new Phaser.Game(config);