class Example extends Phaser.Scene { preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v385'); this.load.atlas('cards', 'assets/atlas/cards.png', 'assets/atlas/cards.json'); } create () { const image = this.add.image(400, 300, 'cards', 'clubsKing'); // Rotate it image.setAngle(45); // Scale it image.setScale(2); // Make interactive image.setInteractive(); // Make draggable this.input.setDraggable(image); this.input.on('dragstart', function (pointer, gameObject) { this.children.bringToTop(gameObject); }, this); this.input.on('drag', (pointe, gameObject, dragX, dragY) => { gameObject.x = dragX; gameObject.y = dragY; }); } } const config = { type: Phaser.WEBGL, parent: 'phaser-example', width: 800, height: 600, scene: Example }; const game = new Phaser.Game(config);
Scan to open on your mobile device
class Example extends Phaser.Scene { preload () { this.load.setBaseURL('https://cdn.phaserfiles.com/v385'); this.load.atlas('cards', 'assets/atlas/cards.png', 'assets/atlas/cards.json'); } create () { const image = this.add.image(400, 300, 'cards', 'clubsKing'); // Rotate it image.setAngle(45); // Scale it image.setScale(2); // Make interactive image.setInteractive(); // Make draggable this.input.setDraggable(image); this.input.on('dragstart', function (pointer, gameObject) { this.children.bringToTop(gameObject); }, this); this.input.on('drag', (pointe, gameObject, dragX, dragY) => { gameObject.x = dragX; gameObject.y = dragY; }); } } const config = { type: Phaser.WEBGL, parent: 'phaser-example', width: 800, height: 600, scene: Example }; const game = new Phaser.Game(config);