Detect phone and tablets

Hey!

Anybody have some rules to detect if the user is on a phone or tablet based on screen size X/Y or something?

I am already using some awesome UB code from BBenk which resizes the stage automatically no matter what their screen size/resolution but now I actually need to know if they are on a tablet or phone so I can throw up a custom scene...

Thanks!

Comments

  • AJaymzAJaymz Member, PRO Posts: 164
    edited February 2015

    @ryast For IOS devices running in Landscape mode:

    Rule - when game.device.screensize.width is 1024. (run ipad scene)
    Else- (run phone scene)

    If your in portrait mode then just check game.device.screensize.height instead of width.

    Im not familiar with Android sizes so hoping your on IOS.

  • ryastryast Member Posts: 145

    Thanks!

  • AJaymzAJaymz Member, PRO Posts: 164

    I was away from my computer when I typed that from my phone, but location to the screen size is actually devices.screen.size.height(or width).

  • ryastryast Member Posts: 145

    Thanks :)

  • robertkdalerobertkdale USAMember Posts: 912

    @AJaymz is right. I use the same technique within my universal builds in order to adjust my actors size and or position on screen. Very easy to do.

    Big Smile Games Play Happy!
    Check out our other GameSalad exclusives.

  • ryastryast Member Posts: 145

    Since I will be targeting Android as well as iPhone I thought I would ask the user if they are on a mobile phone or on a tablet and adjust the screen accordingly... it seems a little more fool proof...

Sign In or Register to comment.