Jump to content

Adjust mouse cordinates for scaled stage?


Recommended Posts

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]
}
Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...