Detect if mobile device?

Get help using Construct 2

Post » Mon Dec 12, 2011 6:15 am

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.
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Mon Dec 12, 2011 8:59 am

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.
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Mon Dec 12, 2011 9:32 am

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.Kyatric2011-12-12 09:33:21
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,805

Post » Mon Dec 12, 2011 10:48 am

aridale, let me know if this kyatric's solution helps you, to know if I release this plugin.
Thx
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Mon Dec 12, 2011 12:53 pm

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.
B
52
S
17
G
15
Posts: 1,029
Reputation: 26,339

Post » Mon Dec 12, 2011 1:40 pm

@septeven, Can you release your plugin to the construct2 community? It will benefit allot of people
B
29
S
12
G
7
Posts: 740
Reputation: 7,849

Post » Mon Dec 12, 2011 2:26 pm

@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.
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Mon Dec 12, 2011 2:31 pm

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?   
B
29
S
12
G
7
Posts: 740
Reputation: 7,849

Post » Mon Dec 12, 2011 2:39 pm

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 ...
B
44
S
12
G
13
Posts: 628
Reputation: 10,471

Post » Mon Dec 12, 2011 2:45 pm

oooh yeah that may be annoying.. Good luck with your plugin though!
B
29
S
12
G
7
Posts: 740
Reputation: 7,849

Next

Return to How do I....?

Who is online

Users browsing this forum: selaus and 0 guests