Detect if mobile device?

Get help using Construct 2

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,839

Post » Mon Dec 12, 2011 3:06 pm

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...!
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Mon Dec 12, 2011 3:08 pm

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

Post » Mon Dec 12, 2011 6:47 pm

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

Post » Mon Dec 12, 2011 7:03 pm

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

Post » Mon Dec 12, 2011 10:34 pm

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

Post » Tue Dec 13, 2011 12:24 am

[QUOTE=aridale] 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.[/QUOTE]
I don't think there's anything wrong with that. Most users will probably use the same (large) window size when playing your game, and if you resize it down and some buttons get bigger, what's the big deal?

Alternatively you could choose the UI on startup and stick to that only. So if your window is over a certain size use a different UI but don't change it if the window size changes.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Previous

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, jul, TELLES0808 and 22 guests