kahootbird Posted June 22, 2019 Share Posted June 22, 2019 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] } Quote Link to comment Share on other sites More sharing options...
bubamara Posted June 22, 2019 Share Posted June 22, 2019 you need to convert global coordinates to local coordinates : http://pixijs.download/dev/docs/PIXI.DisplayObject.html#toLocal function moved(e) { const global = e.data.global; const local = app.stage.toLocal(global); console.log(global.x, global.y, local.x, local.y) } Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 22, 2019 Share Posted June 22, 2019 Use that function: http://pixijs.download/dev/docs/PIXI.interaction.InteractionData.html#getLocalPosition EDIT: its the same as toLocal, yes Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.