How StateKit's 'states as objects' model works
masterStateKit uses a decoupled architecture where the state machine manages a collection of state objects.
- Target Object: The object being controlled (the "focus") is passed to the
SKStateMachineconstructor and is accessible to all states. - State Lifecycle: Every state must implement
begin(entry logic),update(per-frame logic), andend(exit logic). - State Management: The machine caches instances of states once they are used via
changeState<T>(), preventing repeated allocations during transitions. - Registration: You must explicitly add state instances to the machine using
addState()before they can be transitioned to.