Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Screen Dimensions / Resolution / PPI ?

Author
Message
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 21st Jan 2013 14:08
My Problem :

I have a
Nexus 10 (10") (2560 x 1600 at 300ppi)
and a
Galaxy Tab 10.1 (10" approx.) (1280x800 at 149ppi)

So it's important for me to know the PPI to position and size some UI elements of my apps/games.

Maybe there is something which already use the DisplayMetrics class of the android sdk ? (for iOS too but it's easier due to less number of models ?.. ) ?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Jan 2013 14:44 Edited at: 21st Jan 2013 14:44
getDeviceWidth() and getDeviceHeight() will provide the size of the screen on the device. If you are using the percentage system or a virtual resolution you then need to calculate the size in the "virtual" display. For example to create a sprite that is always 10 pixels high and 20 wide:



this.mess = abs(sin(times#))
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 21st Jan 2013 14:48 Edited at: 21st Jan 2013 15:04
not sure if it's relevant for me ..

How can i do if i want a sprite with a width of 1 inch whatever the pixel density is on the device ?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 21st Jan 2013 14:54
Oh, well I'm not sure if you can get the size of the screen in inches from AGK.


this.mess = abs(sin(times#))
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 21st Jan 2013 15:04
Yes that is my problem ... for my virtual joystick i want it approximatively with a size of 1 inch whatever the PPI is (a size of a thumb heh ! :p) ...

For iOS it's easy depending on the GetDeviceName i think (due to less number of differents devices)..

But for android it's more difficult ...

It will become very important with retina like screen or not retina ... (as Shakespeare said : that is the question :p)
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 21st Jan 2013 19:16 Edited at: 21st Jan 2013 19:16
I don't think you can get the screen size at all from android, but it does have the horizontal and vertical dpi in there somewhere.

With the screen physical resolution and DPI, you can work out the screen size, but since you want the dpi anyway, there it is.

Can't speak for other mobile platforms or windows, but I don't see why not.

I've not seen it mentioned in AppGameKit docs, but there are a lot of new commands so you never know.

I'd considered requesting it as a feature, but didn't really have a reason to use it.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 22nd Jan 2013 01:38 Edited at: 22nd Jan 2013 01:42
dpi and ppi are equivalent things i guess

dpi (dot per inch) and ppi (pixel per inch) ... an inch is a physical and universal unit so it can be possible to get the real screen size no ?

the goal is to size correctly a virtual joystick (for example) ... between a 10 inches at 2560pix width and a 10 inches 1280pix width your joystick will appear 2X smaller on one of two screens with identical physical size ... that's not cool

Login to post a reply

Server time is: 2024-11-24 06:14:59
Your offset time is: 2024-11-24 06:14:59