Detect if mobile device?

0 favourites
From the Asset Store
A futuristic device, can be used as radarscreen, optionscreen, infodisplay, research device, ...
  • I want to have different HUDs for my games if their runnin on my iphone vs runnin in my browser. The problem is I cant see any way of tellin during runtime which it is. I tried enabling my iphone controls layer using the touch Device Motion and Device Orientation options but it doesnt work.

  • I developed a quick plugin for my own use and I thought it wouldn't useful to do a public release.

    I can try to release it tonight or tomorrow if it can help.

  • I guess you could compare the Browser.Platform value (browser object) ?

    I don't have a phone, so I can't test it myself, but if the OS (therefore platform) is not mac or windows or another desktop OS, then it should be mobile.

    You could also maybe compare the Browser.Agent value, to make sure it is "for mobile".

    If this doesn't work, than maybe a plugin is required.

    Or maybe Ashley has a tip to save the day.

  • aridale, let me know if this kyatric's solution helps you, to know if I release this plugin.

    Thx

  • could you have it check the window.width or window.height, and if it is less than a certain number, assume it is mobile, and use your mobile hud design, if not, use your other hud design.

    let me know if i've erred grossly...lol.

  • septeven, Can you release your plugin to the construct2 community? It will benefit allot of people

  • smitchell aridale

    I have to clean it a little bit, and add some other functions in order to be more useful for a public release.

    I try to do it for tomorrow.

    If you have some needs, don't hesitate to pm me, i'll try to add them as much as possible.

  • Thanks! your great!!

    I think since your open to taking requests to make your plugin better, you should make a thread to find out what the community needs!

    All I can think of is making things scale to different screens, I know construct already kinda does this, But im sure you can improve it... Right?

  • about a thread, I don't think so, because if I'll do that, I have to do it for all plugins I did/'m doing ...

  • oooh yeah that may be annoying.. Good luck with your plugin though!

  • I'd recommend using harrio's method - change the UI based on the window size rather than the type of phone you detect. If you only show a certain UI if you detect iOS or Android, then your game won't work properly on Symbian, Blackberry, etc...!

  • But then the problem is, ipads dimensions are set to 1024x768. Some computer monitors are that, and the most tablets are different sizes..

    Its easier just to set the width and height properties of objects according to screen size is it not?

  • On reflection, I guess the kyatrics solution is the best.

    My plugin already does that the browser plugin is already doing, the only added thing it's a "shortcut", I mean conditions which test "is Iphone Browser ?", "is Firefox Browser ?",... and if it is, it returns "true".

    I can release it, but I think you can do that with the kyatrics way.

    In the other hand, Smitchell, if you want a plugin which resizes dynamically given the browser used, I think it will take much time to develop it.

  • smitchell,

    i suggested that because the 'horizon' is ever changing with hardware, so you can't possibly keep up. but all tablets are 'generally' the same size, and all phones are 'generally' the same size, in relation. meaning, your layout will look pretty much the same on all tablets if you create a layout for tablets, and likewise for phones. so it might be easier to just a comparison cut off; from x pixels and up - use the tablet layout, and from x pixels and down, use the phone layout.

    but of course, you're free to take your own route. i'm just explaining this method in detail for others who may want to use it.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • that was my original thought... just adjust it based on screen size but then you could just resize your browser window and itll magically think its on a phone or somethin.

    I think the best answer would be a combo of checking the browser agent and resizing the layouts to fix the screen dimensions.

    The agent check mainly to enable touch controls/hud and the rest to fit the display.

    Is there any way to resize the client size (playable area) based on display size? I know you can use fullscreen scale mode but its actin kinda funny in portrait mode on my iphone

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)