void Start() { mPlayerFsm = new QFSMLite(); // 添加状态 mPlayerFsm.AddState(STATE_DIE); mPlayerFsm.AddState(STATE_RUN); mPlayerFsm.AddState(STATE_JUMP); mPlayerFsm.AddState(STATE_DOUBLE_JUMP); mPlayerFsm.AddState(STATE_DIE); // 添加跳转 mPlayerFsm.AddTranslation(STATE_RUN, EVENT_TOUCH_DOWN, STATE_JUMP, JumpThePlayer); mPlayerFsm.AddTranslation(STATE_JUMP, EVENT_TOUCH_DOWN, STATE_DOUBLE_JUMP, DoubleJumpThePlayer); mPlayerFsm.AddTranslation(STATE_JUMP, EVENT_LAND, STATE_RUN, RunThePlayer); mPlayerFsm.AddTranslation(STATE_DOUBLE_JUMP, EVENT_LAND, STATE_RUN, RunThePlayer); // 启动状态机 mPlayerFsm.Start(STATE_RUN); }