GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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 Posts: 164Member, PRO
    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 Posts: 145Member

    Thanks!

  • AJaymzAJaymz Posts: 164Member, PRO

    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 Posts: 145Member

    Thanks :)

  • robertkdalerobertkdale USAPosts: 912Member

    @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 Posts: 145Member

    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.