Skip to main content
Inspiring
January 30, 2017
Answered

Mouse coordinates are doubled on Hi-DPI screens

  • January 30, 2017
  • 1 reply
  • 292 views

Hi,

That's an HTML5 Canvas project.

Let's say I have a timeline_mc, and I want to know, on what part of it a user has clicked.

And that's where I stumbled upon a weird thing: if timeline_mc.x is 200px and I click on the very beginning of it, stage.mouseX returns me 400.

I'm working on a Hi-DPI screen, so that's why x coordinate for mouse is doubled, right? I took out an old notebook with a regular screen to test it out — and yes, stage.mouseX returns 200 on it, as intended.

1. How do I get around this? Halving mouse coordinates in not an option, since I can't know for sure whether you're on an old screen or new.

2. Why do objects use doubled coordinate system, but the cursor doesn't?3. By the way, can you ask an object for relative mouse coordinates in CreteJS? timeline_mc.mouseX is undefined, this helpful feature from AS3 isn't available, I guess?

This topic has been closed for replies.
Correct answer ClayUUID

Is the value of stage.scaleX the same or different on regular and "Hi-DPI" screens?

1 reply

ClayUUIDCorrect answer
Legend
January 30, 2017

Is the value of stage.scaleX the same or different on regular and "Hi-DPI" screens?

Inspiring
January 30, 2017

It's 2 for Hi-DPI and 1 for regular ones.

Thanks for the hint, I've got it!