• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Mouse coordinates are doubled on Hi-DPI screens

Explorer ,
Jan 29, 2017 Jan 29, 2017

Copy link to clipboard

Copied

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?

Views

182

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 30, 2017 Jan 30, 2017

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

Votes

Translate

Translate
LEGEND ,
Jan 30, 2017 Jan 30, 2017

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 30, 2017 Jan 30, 2017

Copy link to clipboard

Copied

LATEST

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

Thanks for the hint, I've got it!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines