Jump to content

Using input.ActivePoint.position.x doesn't seem to work on touch screen devices?


RBrNx
 Share

Recommended Posts

Hi There, I've only recently started using Phaser so apologies for any mistakes I make. I'm trying to use the following code to be able to drag buttons around:

if (this.game.input.activePointer.isDown) {                    if (this.game.origDragPoint) {                        // move the camera by the amount the mouse has moved since last update                        Level1.x -= this.game.origDragPoint.x - this.game.input.activePointer.position.x;                        Level2.x -= this.game.origDragPoint.x - this.game.input.activePointer.position.x;                    }                    // set new drag origin to current position                    this.game.origDragPoint = this.game.input.activePointer.position.clone();                }                else {                    this.game.origDragPoint = null;                }

This seems to work fine when I am using the mouse but it doesn't seem to work on touch screen devices even though from what I've read 'activePointer' can be either a mouse or fingers on a touchscreen. Any ideas?

 

Thanks, RBrNx

Link to comment
Share on other sites

You should really use activePointer.x / y as those values are automatically adjusted for the game scale (where-as position is not).

Thanks very much. It doesn't seem to have fixed the problem though, when I am testing the game in Chrome it works fine but when I change it to emulate a touch screen device the buttons work fine but the camera cannot be dragged around using the above code.

Link to comment
Share on other sites

Hard to tell from the little bit of code up there, but activePointer.x/y are definitely correctly mapped to touch pointers as well as mouse - the forum would be utterly full of complaints otherwise :) I've got it all through the code I'm working on at the moment.

 

Here's a thought though - which version of Phaser is it? Only 2.2.2 (I think) and later work properly under Chrome touch emulation. Fine on the actual device, just not under emulation.

Link to comment
Share on other sites

Hard to tell from the little bit of code up there, but activePointer.x/y are definitely correctly mapped to touch pointers as well as mouse - the forum would be utterly full of complaints otherwise :) I've got it all through the code I'm working on at the moment.

 

Here's a thought though - which version of Phaser is it? Only 2.2.2 (I think) and later work properly under Chrome touch emulation. Fine on the actual device, just not under emulation.

 

I downloaded the latest version of Phaser only the other day so I presume I am running 2.3.0? The touch emulation on Chrome seems to work fine for tapping buttons and such in my game, it just doesn't seem to work in the two places that I use the above code. I'll need to see if I can get a test done on an actual device.

Link to comment
Share on other sites

I actually just went and checked. The Phaser.js I have in my project says that I am using 2.2.2, I have since downloaded 2.3.0 and tried that and neither seem to work with Chrome's touch emulation. However when I run the program and open the console in Chrome I get the message "Phaser v2.0.1 - WebGL - WebAudio" is this right? 

Link to comment
Share on other sites

Well I feel like an idiot now, ended up solving my problem. I had the 2.2.2 & 2.3.0 versions of the Phaser.js but I was still using the 2.0.1 version of Phaser.min.js. Once I downloaded the 2.3.0 version of Phaser.min.js the Chrome Touch Emulation works flawlessly. Thanks!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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