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 be held down for 500ms before it's considered a drag this.input.dragTimeThreshold = 500; 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 be held down for 500ms before it's considered a drag
this.input.dragTimeThreshold = 500;
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();
});
}