aboutsummaryrefslogtreecommitdiff
path: root/examples/state_machine/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/state_machine/main.cpp')
-rw-r--r--examples/state_machine/main.cpp9
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);