Detect platform?

Get help using Construct 2

Post » Sun Apr 14, 2013 12:21 pm

My game has on-screen touch sprites that will appear if they are on a iOS device, but these shouldn't appear on a desktop or any other platform that has a keyboard of some kind.

How do I determine whether the player is on iOS or on a desktop?
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Sun Apr 14, 2013 9:17 pm

Bump. An answer to this would be really nice. Do I need to use a plugin?
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Sun Apr 14, 2013 9:37 pm

You can use this: "On any touch" and enable an entirely event sheet after this, and doing your sprites to appear on this code (setting them invisible doesn't mean they will be untouchable, so, only create then when any touch is detected is a better way to go..)

There is somewhere an option called "touch screen is detected", or "on touch enable", I remember this option but was unable to find it.

Good tutorial:
https://www.scirra.com/tutorials/202/touch-controls-and-a-trick-to-detect-input-method
ImageImageImageImageImageImage
B
93
S
20
G
12
Posts: 1,211
Reputation: 18,473

Post » Sun Apr 14, 2013 10:11 pm

When checking for touch on a specific object, is that object's collision polygon used, or the entire sprite box?
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Sun Apr 14, 2013 10:14 pm

It uses the collision polygon, as does the mouse object.
B
56
S
15
G
10
Posts: 910
Reputation: 11,952

Post » Mon Apr 15, 2013 2:20 am

[QUOTE=TELLES0808] You can use this: "On any touch" and enable an entirely event sheet after this, and doing your sprites to appear on this code (setting them invisible doesn't mean they will be untouchable, so, only create then when any touch is detected is a better way to go..)

There is somewhere an option called "touch screen is detected", or "on touch enable", I remember this option but was unable to find it.

Good tutorial:
https://www.scirra.com/tutorials/202/touch-controls-and-a-trick-to-detect-input-method[/QUOTE]

JavaScript plugins exist for detecting platform. I would love to see one integrated into Construct 2.

What you described works, but it's a hack. Suppose the user is on Android, which is on phones with a keyboard, but that user touches the screen. Given that Android devices vary in screen size, I would prefer the user play with the keyboard instead of using touchscreen controls, which would take up 1/4 of that player's screen at the least.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Mon Apr 15, 2013 3:57 am

If the user is on an Android phone or any touch device with a keyboard you should give the user an option to use touch or the keyboard. Have some sort of variable (either global or in an array) keep track of which input mode the game is in. If a key press event occurs, hide the controls and make them untouchable if they're hidden while enabling the keyboard controls. If a touch event occurs unhide the touch controls, disable keyboard events.
B
58
S
20
G
7
Posts: 305
Reputation: 8,804

Post » Mon Apr 15, 2013 4:01 am

I'm doing this already.

However, Android users may touch the screen and end up using touch controls when they have a keyboard. Considering Android screen sizes vary by phone model (they're not consistent like iPhones are), this means the actual gameplay area is smaller than if they used the keyboard.

But as I said, there are Javascript libraries that detect what kind of platform the app is running on. What we're doing right now is a hack to accommodate different types of input. Why can't C2 integrate one of these libraries or otherwise detect the phone platform?
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Mon Apr 15, 2013 6:24 am

Nevermind, I guess there is a way to detect platform...

https://www.scirra.com/manual/110/browserExcal2013-04-15 06:24:16
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 1 guest