blob: cfb27e7ff217c6d31cadc3bd6015f7d0a98844d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
/**
* Created by robert on 9/15/15.
*/
codeq.makeStateMachine = function(def){
var currState = null;
return {
'transition': function(name){
if(currState !== null) currState.exit();
currState = def[name];
currState.enter.apply(currState,Array.prototype.slice.apply(arguments,[1]));
},
'destroy': function(){
if(currState !== null) currState.exit();
currState = null;
},
'register': function(name,state){
def[name] = state;
}
}
};
codeq.globalStateMachine = codeq.makeStateMachine({});
|