Plugin code organization

Get help using Construct 2

Post » Tue Dec 20, 2011 10:14 pm

I'm making a behavior based on Tween.js. It's very simple just a Tweener that manages a list of Tweens that act over objects. Two classes. But my JS skills are limited (I'm an alphabet programming guy, C++, C#, D etc :) ). How better to organize this in a plugin ? For example where to put Tweener class ? JS code organization support sucks i know so where it better to put the classes ? Something like behaviorProto.Class = function(){...} ? I can't grasp prototipal object system at all :D
Any help will be appreciated thanks.
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Tue Dec 20, 2011 10:27 pm

I basically have the same problem, I come from a few other programming languages, Unfortunately javascript is not my strongest.

But the best thing to do is just look at some of the other plugins found on this link: http://www.scirra.com/forum/c2-plugin-and-behavior-list_topic45158.html

or look at the built in plugins, Good Luck!
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Tue Dec 20, 2011 10:30 pm

you will have to copy and paste the link, I do not know how to give correct links on the forum :S
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Tue Dec 20, 2011 10:32 pm

Put the link after the URL=

Yeah there's a lot of plugins to look at. I took a look at some of them but couldn't find a suitable example. That's one of the big problems of JS: The code looks like crap for people coming from languages like C# or Java or even C++. ( I'm not saying Ashley's code looks like crap :) ) No classes, no modules no import you have to put things inside anonymous functions to handle scoping. Very weakly typed (not typed at all). The worst is i don't see the ones responsible for JS fixing them anytime soon. Ecmascript.Next will have classes and modules supposedly. It's a start.Kiyoshi2011-12-20 22:40:29
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Tue Dec 20, 2011 10:34 pm

Ohh, Try the devlopers forum, Its more about the creation and development of construct,

- Hopefully that link works :)
B
29
S
12
G
7
Posts: 740
Reputation: 7,839

Post » Tue Dec 20, 2011 10:38 pm

Yeah just remembered of that forum. I rarely access it though.
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Tue Dec 20, 2011 11:29 pm

The first pages of the manual SDK offers good link to learn efficiently JS (especially coming from an other language).

An example of integration of a library lies in the physic plugin.
Ash minified and pasted the whole class at first, encapsing it as a var.
He then access this later in his code.

Check his runtime.js
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 » Wed Dec 21, 2011 12:24 am

Awesome Kyatric had forgotten about the Physics plugin. Thanks!
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Wed Dec 21, 2011 12:36 am

Yeah, the Physics thing is a bit of a hack. I thought for a while on how to do it nicely, but it actually ended up easiest to paste the minified code in to the source file and just use that!

Other plugins like Facebook dynamically load the script from the web - you could check that out too.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Wed Dec 21, 2011 1:01 am

Thanks Ashley
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Next

Return to How do I....?

Who is online

Users browsing this forum: makotto, randomly, Walessio and 25 guests