How do I communicate with the surrounding webpage

0 favourites
  • 3 posts
  • 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.



  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thank you briggybros

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)