How easy is it to hook construct 2 up to nodejs?

Discussion and feedback on Construct 2

Post » Fri Sep 21, 2012 12:48 pm

Right now I have a project that is using NodeJS, NowJS and MongoDB/MongooseJS server-side. Client-side, I am using a javascript game engine call MelonJS.

MelonJS is "non-intrusive" in the sense that it is just a set of javascript that I can use to manipulate the canvas. I can easily alter them or use them to call javascript outside of the engine. E.g. I can ask MelonJS to listen to arrow keys and call server-side functions via NowJS when they are pressed.

I am thinking of switching to Construct 2 because it looks like it can shorten development time. But is it easy to call outside javascript from within Construct 2 to hook it up to Node.JS?

E.g.

1) Construct 2 listens to arrow key.
2) Arrow key pressed --> Construct 2 calls server-side function via NowJS.
3) Server processes action and calls client-side Construct 2 function via NowJS.
4) Construct 2 processes the function and carry out the action.

Or do I have to use clunky workarounds?
B
3
Posts: 4
Reputation: 283

Post » Fri Sep 21, 2012 1:50 pm

If I am not mistaken, you could use AJAX to query the NodeJS server.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Fri Sep 21, 2012 2:25 pm

[QUOTE=Mipey] If I am not mistaken, you could use AJAX to query the NodeJS server.[/QUOTE]

I am using HTML5 web-sockets (via NodeJS and Socket.io/NowJS) instead of AJAX. (to achieve "server push", one typically use either AJAX or websockets but not both)

Does Construct 2 work easily with HTML5 web-sockets, and various other HTML5 technologies like NodeJS and Socket.io/NowJS?Legendre2012-09-21 14:26:15
B
3
Posts: 4
Reputation: 283

Post » Fri Sep 21, 2012 4:45 pm

If you're good with Javascript, you can do any kind of javascript coding within C2 using the Javascript SDK.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Fri Sep 21, 2012 11:53 pm

[QUOTE=Ashley] If you're good with Javascript, you can do any kind of javascript coding within C2 using the Javascript SDK.[/QUOTE]

Looks like everything has to be done with "plug-ins". I don't know, I am used to less restrictive Javascript game engines.

Example: http://www.scirra.com/forum/plugin-chat-using-socketio_topic46929.html

The chat plug-in looks complicated. On the other hand, if you have a node.js server up, chat is just a few lines:

1. HTML text input form. Sends text to server-side function.
2. Server-side function calls client-side function.
3. Append HTML with the text.

I hate to get bogged down with trying to get basic functionality working with Construct 2.Legendre2012-09-21 23:54:46
B
3
Posts: 4
Reputation: 283

Post » Sat Sep 22, 2012 4:51 am

Unfortunately at this time C2 going multiplayer through other api's(NowJS, Photon...) is a hurdle in that a plugin needs to be coded. Someone already did a socket.io plugin, but your limited to straight up socket commands without any api that bridges with a server :(. It's an api to work with, but you have to be up to working in code for the server and covering a lot of reinvention of the wheel.

There was an individual who was working on a nowjs plugin, but that project and the user hasn't been seen from in a while. I'm thinking about doing a nowjs plugin, but I'm notoriously slow and get distracted by shinies :P
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Sat Sep 22, 2012 5:09 am

@Legendre: have you checked this topic, more up to date than rex's chat plug ?

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: 7,000
Reputation: 57,795

Post » Sat Sep 22, 2012 9:25 am

Obviously there's going to be some overhead involved in creating and working with a plugin to achieve your multi-player functionality, so you really have to decide whether or not the productivity gains from working with Construct 2 are enough to balance that out.

For a single or small number of projects of smaller scope it may not be worth having to spend the time, but if you're planning on using these platforms repeatedly over a number of projects it will probably start to become more worthwhile -- once you've coded your plug-in, assuming you do a good job of it, you should then be able to simply drop it into multiple projects with only minor adjustments where necessary.


I'd suggest spending a couple of days evaluating the workflow of the free version of Construct 2 and examining the plug-in API so that you can make a more informed decision based on your own needs; only you can really judge how suitable (or not) Construct 2 will be for the types of projects you're working on, and only you will be able to estimate just how much time and effort you might be able to save when compared to working with the libraries you mentioned.
B
24
S
5
G
2
Posts: 104
Reputation: 3,136

Post » Sat Sep 22, 2012 1:56 pm

Thanks for all the input! :)
B
3
Posts: 4
Reputation: 283


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 9 guests