Using javascript with construct ?

0 favourites
  • 12 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • So I am currently making a game in HTML and java script that is web based. I was hoping that because construct is html5 I would be able to integrate it graphically while all the actual scripting is in my java script. I am using notepad++ if that helps.

    any hints on how to link these things and get them to work together?

    sorry if this is a noob question.

  • It's a good question. This may help you.

    Construct 2 JavaScript Plugin and Behavior SDK

  • mmm maybe i should of worded my question better, how can I access construct through the javascript running in my game?

  • What exactly are you hoping to access? Construct 2 is not designed to be a scripting tool - it's entirely done by the event system.

  • Follett: C2 exports a single JS file (which can even be minified) and acts as a "single application". I mean, objects are sealed and will work only within the context of the C2 application, it is likely that you can't use functions from the app in your page, and in the same idea you can't program function in your page and use them in the application.

    Either you program all your application in C2 and export as a "single application" that you embed in your page with no other interaction then displaying it, or you fully program your game in JS, out of C2, and then the C2 application has no way to access/use said code.

    Edit: a last resort could be the use of ajax (to get informations from a database for example) and to program a quick C2 plugin that would execute JS' "eval" function. This way you could feed JS to the plugin and have it executed in the context of your app.

  • So realistically there is no way i can choose the number 2 on my web page and get the number 2 to appear in construct on that page .... as an example.

  • Follett

    What you ask doesn't quite make sense.

    Construct 2 is a Windows based IDE for developing HTML 5 content.

    Are you asking if Construct 2 is capable of receiving content from a webpage?

  • hahah yes, thank you.

  • AJAX object is there for such communication.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Follett, you can also get it to work by writing a javascript plugin as mentioned before. It's just external javascript can't reliably call in to the Construct 2 engine. There are various reasons for this: the minifier and obfuscator, the complexity of the engine, and so on. Writing a plugin is probably the easiest way, or AJAX if you're making requests to other pages.

  • Follett, you can also get it to work by writing a javascript plugin as mentioned before. It's just external javascript can't reliably call in to the Construct 2 engine. There are various reasons for this: the minifier and obfuscator, the complexity of the engine, and so on. Writing a plugin is probably the easiest way, or AJAX if you're making requests to other pages.

    I find this tool pretty useful: javascript obfuscator javascript-obfuscator.org

  • tr

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