Michael Muldoon
posted this on January 18, 2012 03:34 pm
Hi all, I'm working through the SDK and running into a bit of trouble with the Util.StateMachine and IControllers. I don't exactly understand how a transition transfers control from one controller to the other. I think just a short code snippet would help clear things up. Anyone?
Many thanks.
Mickey
Comments
At the time of a state change, the StateMachine will call:
Any call to StateMachine.Tick() will be forwarded to currentState.OnTick() and to StateMachine.Paint() will be forwarded to currentState.OnPaint().
The question that remains now is: when does StateMachine switch states? There are 4 points at which StateMachine will do a transition (if there is a transition queued obviously) and that's:
Personally I don't like the possibility of StateMachine doing a state change between Tick and Paint, so I forked the StateMachine class, removed the 4 state change points and added an explicit ChangeState to be called in the main loop, after Tick and Paint have been called. But that's just my preference.
Sorry I didn't write any more of a "working" code snippet, I hope nevertheless that it's helpful.
Jochen