有限状态机模板 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/NodeControl.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, 'a8658YlpDJP5JRK6eFHwq+g', 'NodeControl', __filename);
// scripts/NodeControl.ts
Object.defineProperty(exports, "__esModule", { value: true });
var FSMManager_1 = require("./FSMManager");
var NodeState1_1 = require("./NodeState1");
var NodeState2_1 = require("./NodeState2");
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var State;
(function (State) {
State[State["state1"] = 0] = "state1";
State[State["state2"] = 1] = "state2";
})(State || (State = {}));
var NodeControl = /** @class */ (function (_super) {
__extends(NodeControl, _super);
function NodeControl() {
return _super !== null && _super.apply(this, arguments) || this;
}
NodeControl.prototype.start = function () {
this.ani = this.getComponent(cc.Animation);
this.fsm = new FSMManager_1.default();
//创建两个状态
var s1 = new NodeState1_1.default(State.state1, this, this.fsm);
var s2 = new NodeState2_1.default(State.state2, this, this.fsm);
this.fsm.StateList = [s1, s2];
//开始执行状态
this.fsm.ChangeState(State.state1);
};
NodeControl.prototype.update = function (dt) {
if (this.fsm.CurrentStateID != -1) {
this.fsm.OnUpdate();
}
};
NodeControl.prototype.stat1 = function () {
console.log("stat1");
this.fsm.ChangeState(State.state1);
};
NodeControl.prototype.stat2 = function () {
console.log("stat2");
this.fsm.ChangeState(State.state2);
};
NodeControl = __decorate([
ccclass
], NodeControl);
return NodeControl;
}(cc.Component));
exports.default = NodeControl;
cc._RF.pop();
}
if (CC_EDITOR) {
__define(__module.exports, __require, __module);
}
else {
cc.registerModuleFunc(__filename, function () {
__define(__module.exports, __require, __module);
});
}
})();
//# sourceMappingURL=NodeControl.js.map
资源文件列表:
finitestate.zip 大约有254个文件