"use strict";
|
cc._RF.push(module, '22b707itTxINYKWjn3CpP90', 'basecontroller');
|
// Scripts/common/basecontroller.js
|
|
"use strict";
|
|
/*-----------------------------------------------------+
|
* 控制处理类相关处理
|
* @author whjing2012@163.com
|
+-----------------------------------------------------*/
|
window.BaseController = cc.Class({
|
"extends": BaseClass,
|
ctor: function ctor() {
|
if (this.constructor.instance) {
|
throw new Error("不能重复实例化一个单例");
|
}
|
|
this.constructor.instance = this;
|
|
if (this.initConfig) {
|
this.initConfig();
|
}
|
|
if (this.registerEvents) {
|
this.registerEvents();
|
}
|
|
if (this.registerProtocals) {
|
this.registerProtocals();
|
}
|
},
|
statics: {
|
instance: null
|
},
|
RegisterProtocal: function RegisterProtocal(cmd, func) {
|
gcore.SmartSocket.bindCmd(cmd, func.bind(this));
|
},
|
SendProtocal: function SendProtocal(cmd, data) {
|
if (!cmd) {
|
Log.error("发送失败,错误的协议号");
|
return;
|
}
|
|
data = data || {};
|
gcore.SmartSocket.send(cmd, data);
|
}
|
}); // 实例化单利
|
|
BaseController.getInstance = function () {
|
if (!this.instance) {
|
new this();
|
}
|
|
return this.instance;
|
};
|
|
cc._RF.pop();
|