Using javascript with construct ?

Get help using Construct 2

Post » Sat Sep 24, 2011 1:14 pm

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.
B
3
G
1
Posts: 20
Reputation: 540

Post » Sat Sep 24, 2011 1:28 pm

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

Construct 2 JavaScript Plugin and Behavior SDK
B
18
S
8
G
7
Posts: 120
Reputation: 5,630

Post » Sat Sep 24, 2011 1:34 pm

mmm maybe i should of worded my question better, how can I access construct through the javascript running in my game?
B
3
G
1
Posts: 20
Reputation: 540

Post » Sat Sep 24, 2011 1:40 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Post » Sat Sep 24, 2011 1:55 pm

@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.Kyatric2011-09-24 13:57:39
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Sat Sep 24, 2011 2:15 pm

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.
B
3
G
1
Posts: 20
Reputation: 540

Post » Sat Sep 24, 2011 2:39 pm

@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?
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,841
Reputation: 48,283

Post » Sat Sep 24, 2011 2:58 pm

hahah yes, thank you.
B
3
G
1
Posts: 20
Reputation: 540

Post » Sat Sep 24, 2011 3:17 pm

AJAX object is there for such communication.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Sat Sep 24, 2011 3:23 pm

@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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,518

Next

Return to How do I....?

Who is online

Users browsing this forum: Braus and 4 guests