import { _decorator, Component, Node } from ‘cc’;
const { ccclass, property } = _decorator;
import * as StateMachine from “javascript-state-machine”;
@ccclass(‘State2Test’)
export class State2Test extends Component {
start () {
var fsm = StateMachine.create({
initial: 'solid',
events: [
{ name: 'melt', from: 'solid', to: 'liquid' },
{ name: 'freeze', from: 'liquid', to: 'solid' },
{ name: 'vaporize', from: 'liquid', to: 'gas' },
{ name: 'condense', from: 'gas', to: 'liquid' }
],
callbacks: {
onMelt: function() { console.log('I melted') },
onFreeze: function() { console.log('I froze') },
onVaporize: function() { console.log('I vaporized') },
onCondense: function() { console.log('I condensed') }
}
});
fsm.melt();
}
}
说debug.ts:102 TypeError: StateMachine.create is not a function