jordibar Posted July 3, 2014 Share Posted July 3, 2014 I don't know how to drag sprites in touch device, I'm trying something like that: function Play() {} Play.prototype = { create: function() { this.game.add.sprite(0, 0, 'background1'); this.fitxa1 = this.game.add.sprite(100, 250, 'fitxa1'); // Input Enable the sprites this.fitxa1.inputEnabled = true; // Allow dragging // enableDrag parameters = (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite) this.fitxa1.input.enableDrag(); //this.fitxa1.input.onDown.add.enableDrag(); // Enable snapping. For the atari1 sprite it will snap as its dragged around and on release. // The snap is set to every 32x32 pixels. // enableSnap(snapEvery32PixelsOnX, snapEvery32PixelsOnY, snap on drag, snap on released) this.fitxa1.input.enableSnap(15, 15, false, true); // Mobile this.game.input.onDown.add(this.toDrag, this); }, update: function() { }, clickListener: function() { this.game.state.start('gameover'); }, toDrag: function(){ // Input Enable the sprites this.fitxa1.inputEnabled = true; // Allow dragging // enableDrag parameters = (lockCenter, bringToTop, pixelPerfect, alphaThreshold, boundsRect, boundsSprite) this.fitxa1.input.enableDrag(); // Enable snapping. For the atari1 sprite it will snap as its dragged around and on release. // The snap is set to every 32x32 pixels. // enableSnap(snapEvery32PixelsOnX, snapEvery32PixelsOnY, snap on drag, snap on released) this.fitxa1.input.enableSnap(15, 15, false, true); console.log('Hola'); } };but it doesn't work, can you help me please??! Thank you! Link to comment Share on other sites More sharing options...
Pedro Alpera Posted July 3, 2014 Share Posted July 3, 2014 Have you tried this example? http://examples.phaser.io/_site/view_full.html?d=input&f=drag.js&t=drag Link to comment Share on other sites More sharing options...
jordibar Posted July 4, 2014 Author Share Posted July 4, 2014 Hi Pedro,Yes, it works fine in navigator, but drag doesn't work in touch screen... I think that the problem should be in CocoonJS, is the service that I'm using to test in my phone. Link to comment Share on other sites More sharing options...
Recommended Posts