[Solved] How do I Grab parameters from the canvas page...

Get help using Construct 2

Post » Mon Dec 08, 2014 4:14 am

I searched a bit before posting this, but could'nt find anything.. Might have missed it given that i'm amazed at how helpful the documentation and tutorials for construct are..

I'm using construct in my game as a "match engine" sort of deal, where the entire game interface is separate, except when playing the actual match.

I need to be able to pass parameters in the URL in order for the construct app knows which match its currently playing and is able to pull the data from the database.

How do I access URL parameters on the start of the layout from the actual canvas html?

Thanks....
Last edited by smassa on Wed Dec 10, 2014 1:48 am, edited 1 time in total.
B
7
S
1
Posts: 27
Reputation: 479

Post » Mon Dec 08, 2014 5:41 pm

Let me elaborate on what i'm trying to do..I want to prototype a racing manager sim (used the simple AI by @SeriouslyCrunchy with some modifications as a starting point, thanks btw)...

Basically, I wanted the actual construct game to only play out the races..

So I would pass parameters when the race started with driver stats, and car performance, as well as starting fuel for pit stops, etc.

The entire "management" part to be written with php, but I can't seem to find anywhere where I could get parameters passed on to the actual construct html... Is that possible at all? Perhaps add a javascript function that gets called when the layout is loaded that will pass the parameters?

Thanks...

EDIT: Tried posting the URL to the actual construct app but it would'nt let me for low rep... putting it again without the link... thanks

http://www.shifty.com.br/sergio/construct_test/
B
7
S
1
Posts: 27
Reputation: 479

Post » Tue Dec 09, 2014 8:37 pm

In case it helps someone, did it thru webstorage object.

Rename the app html file to php, and just save it in the jquery call that creates the c2 canvas.

Code: Select all
jQuery(document).ready(function ()
{         
   // Create new runtime using the c2canvas
   sessionStorage.myid= <?=$_GET['id'];?>;
   cr_createRuntime("c2canvas");
});


Then just get whatever parameters you want in the event editor with webstorage object with expression:

Code: Select all
WebStorage.SessionValue("myid")


Thanks
B
7
S
1
Posts: 27
Reputation: 479


Return to How do I....?

Who is online

Users browsing this forum: adventurist, brunopalermo, Yahoo [Bot] and 33 guests