HTML5 conditionals, for Mobile web
Hi. I'm trying to find out if there's a way to check whether the user is on a Desktop, or Mobile on HTML5, to add controls for Mobile users, playing an HTML5 game in a browser..
#if mobile, only seems to work on native code.
You might find this useful http://haxeflixel.com/documentation/multiple-platforms/
Besides that, if you plan to add a custom compiler conditional, you can easily do so. In your project.xml file, you could add:
<haxedef name="custom_platform" />
And then just check if that flag is set by doing
#if custom_platform doCustomPlatformStuff(); #end
#if mobile, or any other haxedefs for that matter, can't help you here because they're compile-time. You'd need to check whether you're on a mobile browser or not at runtime, since you most likely want to support mobile and desktop platforms with the same HTML5 build.
Thanks a lot! This is what I needed to know.