Detecting touch device (hide mouse cursor)

Started by cat, Fri 16/08/2019 09:53:32

Previous topic - Next topic

cat

Hi!

The game I'm currently working on is intended to be played either on PC or on phone/tablet. It is running nicely on my phone when I copy it to my AGS folder and start it from the AGS app. However, I don't want to show the mouse cursor when running on a touch device.

Is is possible to detect if the game is running on a touch device? Or do I have to provide a second game pack for mobile? Are there compiler switches I can use in combination with ifdev so I don't have to change the code every time I want to build for the other platform?
Or is it best/easiest to build a real apk for my game?

eri0o

You can use System.OperatingSystem'

https://adventuregamestudio.github.io/ags-manual/System.html#operatingsystem

Code: ags

if (System.OperatingSystem == eOSAndroid || System.OperatingSystem == eOSiOS) {
  Display("Running on mobile!");
}
else {
  Display("probably desktop!");
}


I find it easier for testing doing this check only once on game_start and setting a boolean global variable. This allow you being able to change this variable to other value to test something for mobile platform from your computer.

Mouse cursor can then be hidden using mouse.Visible.

https://adventuregamestudio.github.io/ags-manual/Mouse.html?highlight=Mouse#visible

cat

Quote from: eri0o on Fri 16/08/2019 10:14:57
You can use System.OperatingSystem

Very nice! I didn't know this existed. I searched the manual for touch but didn't find anything, of course.

Thanks!

SMF spam blocked by CleanTalk