Detect mobile/tablet by detecting lack of mouse?

Get help using Construct 2

Post » Wed Nov 02, 2016 7:04 pm

Sorry for not looking into this myself before posting but just thought of this, not around Construct to test it, and will probably forget it soon:

What will Mouse.X/Mouse.Y result in on devices without a mouse?

Thinking along the lines of:
-On Layout Start
--If Mouse.X =! (???) then (set conditions for desktop)

Thought this might be an easy way to detect without needing any input from user...
ImageImageImage
B
39
S
22
G
11
Posts: 492
Reputation: 9,925

Post » Wed Nov 02, 2016 8:14 pm

if you add both the mouse object and the touch object it'll return 0 (if the touch object isn't there it seems that touching the screen will make the last position of the touch the mouse coordinate at least on opera mobile), however it will also return 0 on desktop if the mouse is outside the game window at start it seems, so it is not that reliable
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Wed Nov 02, 2016 11:27 pm

There's a system condition that will tell you if the game is being run on a mobile device or not. Look in the manual for more details about it.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Thu Nov 03, 2016 3:23 pm

R0J0hound wrote:There's a system condition that will tell you if the game is being run on a mobile device or not. Look in the manual for more details about it.


Is it fairly accurate?

I know its never perfect and a challenge to update with new systems—I remember when iphone ruined CSS media queries by marking themselves as not a mobile
ImageImageImage
B
39
S
22
G
11
Posts: 492
Reputation: 9,925

Post » Thu Nov 03, 2016 5:26 pm

I don't use mobile but the manual entry lists iPhone being registered as such as I recall when I read it initially. I suppose it's possible for the browser to lie about what it is.
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959


Return to How do I....?

Who is online

Users browsing this forum: Laurent, Yahoo [Bot] and 10 guests