khanh's Forum Posts

  • 2 posts
  • Hi khanh. Thanks for the pointer. In all of the official plugins like the sprite plugin, there is a lot of dot syntax. Is there only certain circumstances where it needs to be avoided?

    I'm not sure how to explain this, though I can give you an example of a case where the dot syntax will cause the problem:

    Without minifying, you can get an object type from runtime by doing this:

    Acts.prototype.ExampleAction = function() {
        var type = this.runtime.types.AnyObjectType; // AnyObjectType is the name of an object type created in C2
        console.log(type);
    };
    [/code:1bkxd7mr]
    In this case, even if you use the bracket syntax ([i]this.runtime.types["AnyObjectType"][/i]), the code won't work after C2 minify the project, since [i]AnyObjectType[/i] has also been renamed.
    
    I can only say that if you access a property from an external library, you should go with the bracket syntax (although you should still be aware of the cases as in my example). The same applies if you want to expose something from your plugin.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi lucid, thank you for your great work here.

    I might have a clue about this:

    Unfortunately, not likely soon. I need to find out why it's happening, and if my suspicions are correct, it will be something that I need to spend a good while hunting down. It's on the todo list, but there's a lot of big things on the list before it, so I wouldn't call it soon, as I don't have an eta yet.

    C2 uses Google Closure Compiler to minify scripts, so the variables and properties (with dot syntax, ex: Object.property) you use will be changed after the minify process. I think this is why your plugin doesn't work after minify.

    This is also noted in the SDK documentation .

    I had the same issue with my plugin before and changing from dot to bracket syntax (Object["property"]) solved it.

    Hope this help.

  • 2 posts