How do I Add my game logic in Javascript

Get help using Construct 2

Post » Mon Nov 23, 2015 1:03 am

Hi,

I'm in the phase of choosing Client GUI technology for my game, and I would like to check how to do few things in C2, for example:

1. Is it possible to combine Javascript code in C2? let's say that at the beginning of the game I need C2 to connect to the game server and there is a JS library I need to use with sockets, protocols etc...

2. Is it possible to call native iOS\Android functions? if YES - What does it take?

3. How do I write game logic\state\data structures\objects in C2 ?

Those questions are crucial for me to understand if I can choose C2 for my GUI Client.

Thank you!
B
3
Posts: 3
Reputation: 181

Post » Mon Nov 23, 2015 4:34 pm

1. Yes. If you add Browser plugin, you can use action Execute Javascript to execute your own javascript.
B
31
S
7
G
4
Posts: 387
Reputation: 4,544

Post » Mon Nov 23, 2015 4:45 pm

@shvalb

If it is crucial, then relying on others isn't really the best policy.

I would recommend downloading the free version and just have a play around for a few days, making the odd prototype or two.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
129
S
29
G
77
Posts: 5,196
Reputation: 54,299

Post » Mon Nov 23, 2015 5:08 pm

1. yes with the sdk:
https://www.scirra.com/manual/15/sdk

2. I think so. Depending on the export method there is a plugin for it to access exposed api features of the exporter. Not all but you could perhaps modify the plugin to access more features of the api.

3. Again with the sdk. You can use the Browser object's execJs action to run snippets of js too, but it's unconnected with the rest of C2 and can break after exporting due to minifying.
B
89
S
30
G
95
Posts: 5,157
Reputation: 63,450

Post » Mon Nov 30, 2015 5:34 pm

When working with a plugin, how easy it is to get data\results from javascript into C2 and vice-versa?

my main needs from JS is for networking with server, i.e: passing\receiving messages and delegate results into C2.

Will it be easier in C3? When C3 will be available?
B
3
Posts: 3
Reputation: 181

Post » Mon Nov 30, 2015 6:07 pm

shvalb wrote:When working with a plugin, how easy it is to get data\results from javascript into C2 and vice-versa?

my main needs from JS is for networking with server, i.e: passing\receiving messages and delegate results into C2.

Will it be easier in C3? When C3 will be available?


Wouldn't using the Ajax-object work for you?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Nov 30, 2015 8:06 pm

I'm not truly familiar with Ajax-Object, but after brief reading it seems like it's Browser oriented mechanism.

I need my game to interact with a server which implement a specific protocol. I need the game to manage a state, login to facebook etc...

Am I missing something with Ajax-Object?
B
3
Posts: 3
Reputation: 181


Return to How do I....?

Who is online

Users browsing this forum: ismael123, Markowicz and 2 guests