Plugin code organization

0 favourites
  • 11 posts
From the Asset Store
5 levels with simple coding Source-code (.c3p) + HTML5 Exported
  • 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.

  • 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!

  • you will have to copy and paste the link, I do not know how to give correct links on the forum :S

  • 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.

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

    - Hopefully that link works :)

  • Yeah just remembered of that forum. I rarely access it though.

  • 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

  • Awesome Kyatric had forgotten about the Physics plugin. Thanks!

  • 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.

  • Thanks Ashley

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley

    FB plugin seems to add something in c2-externs.js.

    // Prevent mangling of FB API
    window.fbAsyncInit = function () {}
    window.FB = function () {}
    window.FB.init = function (i) {}
    window.FB.getLoginStatus = function (r) {}
    window.FB.api = function (q, r) {}
    window.FB.ui = function (q, r) {}
    window.FB.Event = function () {}
    window.FB.Event.subscribe = function (e, r) {}
    window.FB.login = function (r) {}
    window.FB.logout = function (r) {}

    Is it suitable for 3rd part plugin maker to edit this? (Plugin user need to override c2-externs.js)

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