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
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

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
https://www.scirra.com/forum/viewtopic.php?t=152506

And that is why you shall respect the bug reports guidelines, not only giving a capx is making the bug reproductible in one click in a situation they can work with (less time wasted trying to reproduce vague instructions) but also it helps filtering false positives.

Game design is all about decomposing the core of your game so it becomes simple instructions.
B
42
S
17
G
16
Posts: 2,094
Reputation: 15,355


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests