os_device

This variable holds a different constant depending on the device the game is currently being run in.

Syntax:

GML Code Example

os_device


Returns: Constant


Description

This variable holds one of various constant GameMaker: Studio has to tell you which device you are currently running the game on. The following constants can be returned:

Constant Description
device_ios_ipad iPad
device_ios_ipad_retina Newer iPad with Retina display size of 2048 x 1536
device_ios_iphone6 iPhone6 with display size 1334 x 750
device_ios_iphone6plus Larger iPhone 6 with display 1920 x 1080
device_ios_iphone5 iPhone5 with display size 640 x 1136)
device_ios_iphone Older iPhone/iPod Touch (480 x 320 screen) or Android phone
device_ios_iphone_retina Newer iPhone/iPod Touch with Retina display of 960 x 640
device_emulator The device is actually an emulator (Windows Phone or Android)
device_tablet Android tablet
device_ios_unknown Unknown or not iOS

Example:

GML Code Example

if os_browser = browser_not_a_browser
    {
    switch (os_device)
       {
       case device_ios_ipad: global.Config = 2; break;
       case device_ios_iphone: global.Config = 3; break;
       case device_ios_iphone_retina: global.Config = 4; break;
       case device_ios_unknown: global.Config = 5; break;
       }
    }
 else
    {
    global.Config = 1;
    }
 

The above code checks to see if the game is running in a browser or not and sets a global variable to a value depending on the result of the check.





No Examples Submitted

Does this page need better examples? Be the first to Submit

No Edits Suggested

Is this page unclear or not descriptive enough? Suggest an edit to the page and with enough upvotes your changes will be made.

No Questions Have Been Ask

Do you have a question about this page? Ask it Here