Navigate to layout by url

  • Hey all,

    I'm wondering if there's a way to load a specific layout via a url or hash after exporting to HTML5.

    For example, say your game is at mygame.com. Browsing to mygame.com will bring up your default first layout but browsing to mygame.com#alternate or mygame.com?layout=alternate would bring up another layout.

    It would still load your whole application but the first layout would be determined in the url. It seems like there should be a way to do this since previewing the game starts on whichever layout your were last editing.

    Currently, I'm considering some kind of hack where I make the first layout invisible, set a variable to the browser's url, inspect that then load another layout. I'm not sure if this will actually work and was wondering if there's a simpler way of doing this.

    Anyone else run into this? Please let me know. Thanks.

  • Just use the Browser object to read the query string on startup, then jump to the right layout.

  • Ashley, can you elaborate on how to do that? I tried using:

    System->Compare Two Values with Browser.Hash = 'myhash' and it doesn't seem to evaluate to true.

    Thanks.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ashley, can you elaborate on how to do that? I tried using:

    System->Compare Two Values with Browser.Hash = 'myhash' and it doesn't seem to evaluate to true.

    Thanks.

    The string after the hash at the end of the URL, including the hash. For example, if the current URL is scirra.com/mygame/index.html this returns "#teapot".

    Maybe try comparing "#myhash" instead of "myhash"

    moonraystudios

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)