state-machine.js 有限状态机实例代码

代码语言:html

所属分类:其他

代码描述:state-machine.js 有限状态机实例代码

代码标签: 实例

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/state-machine.js"></script>
    <script type="text/javascript">
        var fsm = new StateMachine({
            init: 'solid',
            transitions: [{
                name: 'melt', from: 'solid', to: 'liquid'
            },
                {
                    name: 'freeze', from: 'liquid', to: 'solid'
                },
                {
                    name: 'vaporize', from: 'liquid', to: 'gas'
                },
                {
                    name: 'condense', from: 'gas', to: 'liquid'
                },
            ],
            methods: {
                onMelt: function() {
                    console.log('I melted')
                },
                onFreeze: function() {
                    console.log('I froze')
                },
           .........完整代码请登录后点击上方下载按钮下载查看

网友评论0