Pointer Move Event
Learn how to use the 'pointermove' event to track the pointer's position and spawn images at its current coordinates.
800 × 600
class Example extends Phaser.Scene
{
preload ()
{
this.load.setBaseURL('https://cdn.phaserfiles.com/v410');
this.load.spritesheet('balls', 'assets/sprites/balls.png', { frameWidth: 17, frameHeight: 17 });
}
create ()
{
this.input.on('pointermove', function (pointer)
{
this.add.image(pointer.x, pointer.y, 'balls', Phaser.Math.Between(0, 5));
}, this);
}
}
const config = {
scale: { mode: Phaser.Scale.FIT },
type: Phaser.AUTO,
parent: 'game-container',
width: 800,
height: 600,
scene: Example
};
const game = new Phaser.Game(config);