All Questions

Community

z
Zoidberg zoidbergforpresident

Is checking for input in a state a good idea?

Seems a bit out of place to me, I may be missing something.
  • Nathan Lovato replied
    Why would that be an issue? There's one state running at a time, and events get funneled down to it by the state machine. This way you know that only one state (and its parents) will be handling input at a given point in time. With this state pattern, each behavior is self contained: update loop, input handling, event callbacks are all in one place. This helps solve the problem of finding where code is. If I want to change the hook movement code, I know it's in the hook state. The move code, in the move state and its descendents.
  • z
    Zoidberg zoidbergforpresident replied

    Well, it sure does work but putting input logic into state themselves, is this the best way possible? I mean they have to be linked somewhere, sure, but is this the right pattern? That's what I wondered.

    Just asking. :)