Jump to content

Dragging a sprite in Chrome Dev tools


pencilking2002
 Share

Recommended Posts

Hi. I need to implement some dragging in my game. The code below works fine on Desktop and Mobile but when I turn on chrome dev tools on desktop (for testing on mobile) the drag functionality doesn't work, except for the sprite jumping around.

 

Its convenient to be able to test in chrome dev tools, so if anyone has a clue as to why it doesn't work please let me know. Thanks!

 

// Create paddle
paddle = game.add.sprite(game.world.centerX, game.world.height - 100, 'sprites', 'platform.png');
paddle.anchor.setTo(0.5, 0.5);
 
paddle.inputEnabled = true;
paddle.input.enableDrag(false);
paddle.input.allowVerticalDrag = false;
Link to comment
Share on other sites

I had this problem too, I think it's actually bugged in Chrome (try several different phone presets, some of them should work). I managed to fix it and I *believe* that this is the change that made it (it was necessary for something related to Chrome dev tools anyway :P ):

 

In Phaser.Mouse (src/input/Mouse.js):

start: function () {        if (this.game.device.android && this.game.device.chrome === false && this.game.device.touch)        {            //  Android stock browser fires mouse events even if you preventDefault on the touchStart, so ...            return;        }//LEAVE THE REST UNCHANGED}

The "this.game.device.touch" check is added.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...