一个游戏框架 cocos creator v2.0.10
立即下载
资源介绍:
一个游戏框架 cocos creator v2.0.10,消息传递过程
(function() {"use strict";var __module = CC_EDITOR ? module : {exports:{}};var __filename = 'preview-scripts/assets/Scripts/ManagerBase.js';var __require = CC_EDITOR ? function (request) {return cc.require(request, require);} : function (request) {return cc.require(request, __filename);};function __define (exports, require, module) {"use strict";
cc._RF.push(module, '2415fILMylHnZW0vu2qpFfN', 'ManagerBase', __filename);
// Scripts/ManagerBase.ts
Object.defineProperty(exports, "__esModule", { value: true });
var ComponentBase_1 = require("./ComponentBase");
var Message_1 = require("./Message");
var ManagerCenter_1 = require("./ManagerCenter");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var ManagerBase = /** @class */ (function (_super) {
__extends(ManagerBase, _super);
function ManagerBase() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.ReceiveList = [];
return _this;
}
ManagerBase.prototype.onLoad = function () {
_super.prototype.onLoad.call(this);
this.messageType = this.SetMessageType();
ManagerCenter_1.default.Manager.push(this);
};
ManagerBase.prototype.SetMessageType = function () {
return Message_1.MessageType.Type_UI;
};
//注册消息监听
ManagerBase.prototype.RegisterReceiver = function (cb) {
this.ReceiveList.push(cb);
};
ManagerBase.prototype.ReceiveMessage = function (message) {
_super.prototype.ReceiveMessage.call(this, message);
if (message.Type != this.messageType) {
return;
}
for (var _i = 0, _a = this.ReceiveList; _i < _a.length; _i++) {
var cb = _a[_i];
cb.ReceiveMessage(message);
}
};
ManagerBase = __decorate([
ccclass
], ManagerBase);
return ManagerBase;
}(ComponentBase_1.default));
exports.default = ManagerBase;
var EnemyManager = /** @class */ (function (_super) {
__extends(EnemyManager, _super);
function EnemyManager() {
return _super !== null && _super.apply(this, arguments) || this;
}
EnemyManager.prototype.SetMessageType = function () {
return Message_1.MessageType.Type_Enemy;
};
return EnemyManager;
}(ManagerBase));
cc._RF.pop();
}
if (CC_EDITOR) {
__define(__module.exports, __require, __module);
}
else {
cc.registerModuleFunc(__filename, function () {
__define(__module.exports, __require, __module);
});
}
})();
//# sourceMappingURL=ManagerBase.js.map
资源文件列表:
Frame.zip 大约有235个文件