How do I Pass A URL Variable to Initialize the Game?

Get help using Construct 2

Post » Wed Jul 09, 2014 3:19 pm

I have an html5 game that I want to be able to launch by passing it a variable in an html link.

Basically, it a word game and I have two web servers, one that runs a word database tool, and one that runs the game.

I want to be able to build links from one server so that depending on the letter set being used, a user can call the game with a letter key, ie: http://mygame.com/index.html?key=ABCDE and the game would initialize based on that key.

I know I could save a file with the key and call it with AJAX at the beginning of the game, but is there away to pass a variable directly in a URL to the game (this would be very helpful in building links) ?

Many thanks!
B
11
S
2
Posts: 86
Reputation: 1,001

Post » Wed Jul 09, 2014 4:05 pm

You can use the "QueryString" Browser Expression. As per the manual, it would return "?key=ABCDE" in your example. You could then parse it to retrieve the value of the desired key.
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Wed Jul 09, 2014 4:23 pm

Cool! ... I appreciate your help :-)
B
11
S
2
Posts: 86
Reputation: 1,001


Return to How do I....?

Who is online

Users browsing this forum: luckyrawatlucky, nahima, Yahoo [Bot] and 6 guests