Javascript SDK update for r96

0 favourites
  • 1 posts
From the Asset Store
Fantasy Game includes more than 600 sound effects inspired by hit computer games like World of Warcraft and Diablo.
  • Hi all,

    There's a minor update to the Javascript SDK following r96. Click here to download it again:

    http://www.scirra.com/downloads/javascript-sdk-template.zip

    From the r96 changelog you may note the following performance item:

    ..the javascript code for actions, conditions and expressions not actually used in the project are now removed by Closure Compiler when exporting. This helps reduce the download size and improve startup time on mobile (since there is less javascript to parse).

    In order for unused conditions, actions and expressions to be removed by Closure Compiler, they have to be written with a slightly different syntax. The old style was this (only actions shown, it's the same for all three, and same for behaviors except using 'behaviorProto'):

    // Actions
    pluginProto.acts = {};
    var acts = pluginProto.acts;
    
    acts.Action1 = function ()
    {
         // ...
    };
    
    acts.Action2 = function ()
    {
         // ...
    };
    
    // ...

    Unfortunately Closure Compiler is not able to remove unused conditions, actions or expressions with this style of code. The new syntax is:

    // Actions
    function Acts() {};
    
    Acts.prototype.Action1 = function ()
    {
         // ...
    };
    
    Acts.prototype.Action2 = function ()
    {
         // ...
    };
    
    // ...
    
    pluginProto.acts = new Acts();

    This way has the same result at runtime, but Closure Compiler can remove unused conditions, actions or expressions. This helps keep the runtime slim since only functions your project actually uses are kept in the resulting javascript.

    All official plugins and behaviors have already changed to the new style. Note the old style is backwards compatible and will continue to work at runtime just fine! You do not need to change old plugins. However, every single condition, action and expression will be included regardless of if they are actually used. Download the new SDK template and overwrite your current one if you've saved it, and this will make sure you use the new style for all future plugins.

    Thanks for your help with plugin and behavior development!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)