domza Posted August 27, 2015 Share Posted August 27, 2015 Hi there, I am trying to get touch position in the game at a given point within the world, although I am getting different results on different devices. Things to note are: The game.world.scale x/y values are increased as I am trying to make it look like it is zoomed inThe game.renderer height/width is not the same as the game height/width (I am stretching the canvas to fill the screens height and centering it)The x/y scale values are always the sameThe camera is moving around the worldHere is the code I currently have to get the touch point and covert it to the world position: var scale = game.world.scale.x; var clickX = e.worldX / scale * (game.renderer.width / game.width) - game.camera.x / scale; var clickY = e.worldY / scale * (game.renderer.height / game.height) - game.camera.y / scale; return { x: clickX, y: clickY };The accuracy of this gets worse as I move away from the top left of the world. It is also worse on the iPhone 6+ compared to the Galaxy S6. I think this may have something to do with the offset? Not sure what the issue is, what exactly is WorldX supposed to return? Thanks,Dom Link to comment Share on other sites More sharing options...
Skeptron Posted August 27, 2015 Share Posted August 27, 2015 Why don't you use pointer.x and pointer.y? Doc : http://phaser.io/docs/2.4.2/Phaser.Pointer.html#x I'm not using pointers myself, just trying to help. Maybe this or clientX and clientY might return what you expect. Link to comment Share on other sites More sharing options...
Recommended Posts