How do I communicate with the surrounding webpage

Get help using Construct 2

Post » Thu Jan 15, 2015 9:34 am

Hi, apologies, complete newbie,
Before I get stuck into construct2, I want to know if I make a javascript game that is embedded within a webpage (div construct2), can the game receive some inputs from other elements of the page (ie buttons), and can it also update the page (ie text fields). If it could construct2 would be a slam dunk for me.

Thanks
Ben
B
7
S
1
Posts: 33
Reputation: 501

Post » Thu Jan 15, 2015 11:27 pm

I would be inclined to say yes. Given C2's browser object there is an option to execute JS code (It is noted that the Javascript SDK should be used if possible). This can either be used as a void method or to return a string or number.

To check if a button has been pressed on the page, you can store when the button has been pressed on the page using JS in the page's html. While also checking this value from C2 every tick, and if true, set to false. This seems like it should work, but I've never tried.

To update a text field you can again use the execute JS action, manipulating the page as if you were writing inline JS.

Please note I've never tried to do this myself so I do not know if it will work.
Nothing goes unanswered!
B
24
S
5
G
1
Posts: 434
Reputation: 3,446

Post » Thu Jan 22, 2015 10:43 pm

Thank you briggybros
B
7
S
1
Posts: 33
Reputation: 501


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests