自定义ccclass有个黄色的提示是什么问题啊

v1.4.1beat2.1

用下面的代码会提示:
Can not instantiate CCClass ‘undefined’ with arguments.

只截了部分代码
var Area = cc.Class({

ctor: function (opts, map, ui) {
    this.playerId = opts.curPlayer.id;
    this.entities = {};
    this.players = {};
    this.map = null;
    this.componentAdder = new ComponentAdder({area: this});
    this.gameui = ui;
    this.scene = ui.mapNode;

    //测试
    //this.scene;
    this.skch = opts.skch;
    this.gd = opts.gd;
    this.gv = opts.gv;

    this.isStopped = false;
    this.init(opts, map, ui);
}

ctor的声明不能有参数
需要在ctor的方法体里用arguments获取
具体可查看文档 构造函数一栏
http://www.cocos.com/docs/creator/scripting/reference/class.html

文档有暗示用argument初始化得自己保证无参构造函数可用。。所以不妨在构造后用链式方法初始化
可以更灵活 比如
在脚本写多一个init方法用来初始化
init:function(args){this._args=args}
在实例化的时候可以
new CustomClass().init(args)

1赞

1.5 版本会优化这部分体验

现在都2.0.1了撒,为什么这个提示还是存在?
你们的解释是怎样的呢

2.0.1还是有这个报错。

2.1.0 都还有

  • v2.1.2

请给个代码片段和详细报错信息

Can not instantiate CCClass ‘undefined’ with arguments.

ctor 不允许定义构造参数 或者 通过 arguments 获取