Scaling with devicePixelRatio

Discussion and feedback on Construct 2

Post » Thu May 23, 2013 9:21 am

Hi all,

So this is something that's bothered me for a while.

If I'm trying to create a cross-platform scaling solution, I really want it to take into account pixel density. If everything is scaled up uniformly that isn't a problem, but usually you wouldn't want the button size on mobile to scale up proportionally on larger displays.

Ideally I'd be able to do this:

Width * (96/PPI)

Or something similar so that the real-world size of the width was consistent across devices with different pixel densities.

Has anyone looked at this before?thehen2013-09-13 16:54:25
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Post » Thu May 23, 2013 12:20 pm

Can't different screens have the same size, and have different ppi?
Also, how would you get the ppi?
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Tue May 28, 2013 10:36 am

Isn't that you are looking?

http://flamma-beta.com/HTML5/zoompng/

Click anywhere to switch zoom in/out.

Top left, original resolution.

Top right, 8 bit PNG high resolution.

Pink, 16 bit PNG high resolution.
B
95
S
25
G
20
Posts: 3,052
Reputation: 22,613

Post » Fri Sep 13, 2013 4:52 pm

Hi all,

This is something I'm consistently struggling with still.

The problem lies in WindowWidth/WindowHeight/ScreenWidth/ScreenHeight

For example, how do I differentiate between an iPad 1 and iPhone 5? The pixel width of an iPhone 5 is greater than iPad, so there is no correspondence to physical size.

I can implement devicePixelRatio into an expression as a plugin. Then I could use the following:
[CODE]If (ScreenWidth/devicePixelRatio >= 1024)[/CODE]This would target any iPad and general bigger displays.
[CODE]If (ScreenWidth/devicePixelRatio <= 568)[/CODE]This would target any iPhone and smaller devices.

My question is - haven't other people run into this problem and does my solution make even sense?thehen2013-09-13 17:01:43
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Post » Fri Sep 13, 2013 5:08 pm

the HTML5 export includes some scaling detecting the OS and browser in its META tags, but I assume you're talking about all platforms, right?

ViewPort doesn't help?

Lastly, isn't there something about detecting in what kind of OS the app is running? That'd be a nice suggestion to pitch.
B
12
S
3
G
1
Posts: 347
Reputation: 2,866

Post » Fri Sep 13, 2013 5:19 pm

@ghost yeah this is across all platforms without any sort of OS detection.

There's lots of OS detection stuff already, but that wouldn't account for, say, a retina Macbook. My solution would/should?
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Post » Fri Sep 13, 2013 6:54 pm

IDK...
Have you asked the Ubi guys?
or Ashley?
B
12
S
3
G
1
Posts: 347
Reputation: 2,866

Post » Fri Sep 13, 2013 11:20 pm

I don't think the Ubi guys will have run into this issue yet, but I've popped Ashley an email.
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Post » Mon Sep 16, 2013 4:19 pm

Would it solve this to expose devicePixelRatio through the Browser plugin?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Mon Sep 16, 2013 6:04 pm

@Ashley yep it would! I was wondering whether this would be the right approach though - it concerns me that others haven't run into the same issue?
Moderator
B
72
S
13
G
11
Posts: 900
Reputation: 11,783

Next

Return to Construct 2 General

Who is online

Users browsing this forum: DTernes, Yahoo [Bot] and 2 guests