- 测试工程 https://gitee.com/scober/ccstate-machine
- 导入state-machine
- 安装setup/staruml-5.0-with-cm.exe
- 新建uml文件,编辑uml文件中的状态机,初始状态名称必须为 none

- 点击tools/ccstate-machine 生成js文件xx.js,将xx.js拷贝到自己需要的目录
- 拖入xx.js到编辑器
- 使用
cc.Class({
extends: cc.Component,
properties: {
TestStateNode: cc.Node
},
onLoad() {
let TestStateComp = this.TestStateNode.getComponent("TestState");
TestStateComp.bindTargetActions(this);
this.teststatefsm = TestStateComp.fsm;
},
// 第一步
onEnterStep1(fsm, name, from, to, args) {
fsm.to_step2(); //第二步
},
// 第二步
onEnterStep2(fsm, name, from, to, args) {
},
});
