ForgeableSum Posted December 24, 2014 Share Posted December 24, 2014 Is there a way to get a sprite's x and y coordinates relative to the window instead of the world? Something like .pageX or .pageY the pointer has. Link to comment Share on other sites More sharing options...
lewster32 Posted December 26, 2014 Share Posted December 26, 2014 If you get the top and left offsets of the Phaser canvas you can add those to your sprite's x and y values to get the page position of your sprite. I don't know if Phaser has the offsets to hand (it probably does) but with jQuery you can do this:var offsets = $(game.canvas).offset();console.log(offsets.top, offsets.left); Link to comment Share on other sites More sharing options...
ForgeableSum Posted December 28, 2014 Author Share Posted December 28, 2014 I ended up using camera.x and camera.y to get the position of the window relative to the world. from there it's just a matter of adding those values to the window-relative click/sprite coordinates to get the world position values. Link to comment Share on other sites More sharing options...
Recommended Posts