! Can not instantiate CCClass with arguments

how can i make a cc.Class that has a constructor with arguments?..

// BaseTest
cc.Class({
    ctor (args)
    {
        // do something to args
    }
});

// Test
cc.Class({
    extends : BaseTest
    ctor (args)
    {
        // do something to args
        this._super(args);
    }
});

it gives me this warning Can not instantiate CCClass with arguments.
what is the fix for this? thanks

Use

// Test
cc.Class({
    extends : BaseTest
    ctor () {
        var arg = arguments[0];
        this._super(arg);
    }
});

And you shoud NOT call _super in your constructor!

1 Like