Connecting HTML/JS with c2 canvas

0 favourites
  • 1 posts
From the Asset Store
Pixel Destruction like in "Worms" (Drawing Canvas based)
  • Hi there. I want to know if its possible ... well ... i bet it is, so maybe i should ask if its hard to do so: connecting my own HTML and javascript code with game compiled with construct 2 ?

    What I'm trying to achive is to make game menu in HTML+JS, and then, after pressing button "PLAY" it loads construct2 canvas and starts the game with some particular parameters set with HTML elements.

    Simple example, I have many options that affect game difficulty, lets say:

    • number of enemies
    • health of enemy
    • damage of enemy
    • speed of enemy

    etc ...

    All those options are set by player, they are not automatic. I want to use for this purpose HTML forms that save those options in javascript variables. After player set game configuration and press play button, games starts, and all object vars inside game scale to the settings.

    Is it hard to do ? I'm completely new to c2 so I'm dont know many of its abilities, but I suppose that if there is possibility to access WebStorage - maybe I should save those settings inside WebStorage with my own javascript, and then read it in the c2 app ?

    Or maybe is there better approach, like accessing javasciprts global object, so if I set configuration inside simple javascript vars, I can read them later inside c2 game ?

    Or maybe even better - is it easy to access HTML DOM so I can read config directly from value of HTML input elements ?

    Another question about HTML+JS and C2: Can I easly use, lets say, jQueryUI for ingame dialogs ? I really dont like way of making GUI inside C2, so I thought about using thing I know well and like: jQueryUI, for making ingame dialogs. Is it possible ? Is it easy ? Can I easly show up dialog from C2 app ? It involves calling javascript function that is set inside HTML document but is outside C2.

    Is it easy to access HTML DOM inside such dialogs, for lets say, again read HTML form ?

    How about sending signals from outer HTML to C2 app ? If i make game menu panel with buttons that after clicking should call some action inside a game - is it possible ? Lets say I have a HTML button spawning unit inside strategy game, is it easy to achive such a thing ?

    Since its a long post, lets sum it up with question list:

    1. How to run C2 app with HTML/JS button ?

    2. How to read data inside HTML DOM / JS scope from C2 app ?

    3. How to run (open) jQueryUI dialogs from C2 app ?

    4. How to retrive data inside jQueryUI dialogs from C2 app ?

    5. How to send signal (execute C2 action/function or set an variable inside C2 app) from HTML to C2 app ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)