Navigate to layout by url

Get help using Construct 2

Post » Tue Apr 30, 2013 6:00 pm

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.Schism2013-04-30 18:01:33
B
3
Posts: 3
Reputation: 306

Post » Wed May 01, 2013 1:42 am

Just use the Browser object to read the query string on startup, then jump to the right layout.
Scirra Founder
B
399
S
236
G
89
Posts: 24,525
Reputation: 195,382

Post » Wed Nov 06, 2013 4:59 pm

@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.
B
5
Posts: 11
Reputation: 272

Post » Wed Nov 06, 2013 5:17 pm

[QUOTE=moonraystudios] @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.[/QUOTE]

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

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

@moonraystudiosAphrodite2013-11-06 17:24:27
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests