Build games as easily as you play them — join the Phaser Beam waitlist for Early Access.
                
            
            var config = { type: Phaser.WEBGL, parent: 'phaser-example', scene: { preload: preload, create: create } }; var game = new Phaser.Game(config); function preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v355'); this.load.image('eye', 'assets/pics/lance-overdose-loader-eye.png'); } function create () { var image = this.add.sprite(200, 300, 'eye').setInteractive(); this.input.setDraggable(image); // The pointer has to move 16 pixels before it's considered as a drag this.input.dragDistanceThreshold = 16; this.input.on('dragstart', function (pointer, gameObject) { gameObject.setTint(0xff0000); }); this.input.on('drag', function (pointer, gameObject, dragX, dragY) { gameObject.x = dragX; gameObject.y = dragY; }); this.input.on('dragend', function (pointer, gameObject) { gameObject.clearTint(); }); }
var config = {
    type: Phaser.WEBGL,
    parent: 'phaser-example',
    scene: {
        preload: preload,
        create: create
    }
};
var game = new Phaser.Game(config);
function preload ()
{
        this.load.setBaseURL('https://cdn.phaserfiles.com/v355');
    this.load.image('eye', 'assets/pics/lance-overdose-loader-eye.png');
}
function create ()
{
    var image = this.add.sprite(200, 300, 'eye').setInteractive();
    this.input.setDraggable(image);
    //  The pointer has to move 16 pixels before it's considered as a drag
    this.input.dragDistanceThreshold = 16;
    this.input.on('dragstart', function (pointer, gameObject) {
        gameObject.setTint(0xff0000);
    });
    this.input.on('drag', function (pointer, gameObject, dragX, dragY) {
        gameObject.x = dragX;
        gameObject.y = dragY;
    });
    this.input.on('dragend', function (pointer, gameObject) {
        gameObject.clearTint();
    });
}