diff options
author | chai <chaifix@163.com> | 2018-11-08 20:10:22 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-11-08 20:10:22 +0800 |
commit | 6bb692df3008c810688bd5be9d824f25455d1a7f (patch) | |
tree | 187bc521f92a9c308d6536e2edfe9b819313aa19 /examples/state_machine/main.cpp | |
parent | 186c68f964868eff0ba543777f47ff036735ef77 (diff) |
*修改状态机
Diffstat (limited to 'examples/state_machine/main.cpp')
-rw-r--r-- | examples/state_machine/main.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/state_machine/main.cpp b/examples/state_machine/main.cpp index fb11fa3..7d83d2b 100644 --- a/examples/state_machine/main.cpp +++ b/examples/state_machine/main.cpp @@ -14,7 +14,6 @@ using namespace JinEngine::Time; ParticleSystem* p; StateMachine sm; Timer timer; -Timer::Handler* hnd; void onLoad() { sm.addState("Run"); @@ -35,16 +34,18 @@ void onLoad() sm.addTranslateListener("Idle", "Run", [](void* p) { cout << "From Idle to Run" << endl; }); + sm.addUpdateListener("Run", [](void* p) { + cout << "run" << endl; + }); Window::get()->show(); - hnd = timer.every(500, [](void*) { + Timer::Handler* hnd = timer.every(500, [](void*) { cout << sm.getCurrentState() << endl; }, NULL); timer.after(2500, [](void*) { //sm.setParameterb("run", true); sm.setParametert("run"); - //timer.cancel(hnd); }, NULL); - timer.after(5000, [](void*) { + timer.after(5000, [=](void*) { sm.setParameterb("idle", true); sm.setParametert("run"); timer.cancel(hnd); |