Search code examples
game-makergame-maker-languagegame-maker-studio-2

In Gamemaker Studio 2 how can I find out in code whether the platform is HTML5 or not?


I want to be able to run or not run code depending on which platform I am building for. Some code should only run for the HTML5 platform. How can I found out whether the platform being run is HTML5 inside my gamemaker events?


Solution

  • Found an answer thanks to: Charanor. https://gamedev.stackexchange.com/questions/152719/in-gamemaker-studio-2-how-can-i-find-out-in-code-whether-the-platform-is-html5-o

    You can check what browser the game is currently being run in with the os_browser constant. If the game is not being run in a browser the constant will be browser_not_a_browser. So to check if it is being run in a browser simply do:

    if os_browser != browser_not_a_browser {
         // Being run in a browser
    }