Quantcast
Channel: Pixi.js Latest Topics
Viewing all articles
Browse latest Browse all 3978

Adjust mouse cordinates for scaled stage?

$
0
0

The code would look something like that below. Basically I'm wondering if you scale the stage to the screen size, if there is a way to adjust the mouse X and Y coordinates to the new size -- the coordinates provided I've found that it's a bit offset the further toward bottom right you go from the pointermove event.

//Scale stage
var resolution_width = 1024
var resolution_height = 768

app.stage.scale.x = window.innerWidth / screen_width;
app.stage.scale.y = window.innerHeight / screen_height;

//Get mouse x and y on mouse move
app.stage.pointermove = moved;
function moved(e)
{
  console.log([e.data.global.x,e.data.global.y]
}

Viewing all articles
Browse latest Browse all 3978

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>