From df70a616f58aa51ff6375a824fc18cbbc369e43b Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 22 Dec 2018 13:45:32 +0800 Subject: +statemachine --- bin/game/main.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'bin/game/main.lua') diff --git a/bin/game/main.lua b/bin/game/main.lua index 62086da..d521fc2 100644 --- a/bin/game/main.lua +++ b/bin/game/main.lua @@ -73,6 +73,17 @@ function jin.core.onLoad() jin.graphics.pushMatrix() jin.graphics.translate(0, 0) --jin.graphics.rotate(0.2) + + local fsm = jin.ai.newStateMachine({ + events = { + { name = 'startup', from = 'none', to = 'green' }, + { name = 'panic', from = 'green', to = 'red' }, + { name = 'calm', from = 'red', to = 'green' }, + }}) + print(fsm.current) -- "none" + fsm:startup() + print(fsm.current) -- "green" + end function jin.core.onEvent(e) -- cgit v1.1-26-g67d0