All Questions


Eduardo Pugliese

Code vs interface signal connection

The enter/exit signal connection can be made directly through the Node's "Signals" interface? if that so, why have you decided to do it via code, isn't it cleaner and more visible through the GUI?, it's my first time using signals so i'm not sure what i say makes sense.
  • Nathan Lovato replied

    No, you couldn't connect signals through the interface in that case, what we're doing is different.

    When you connect a signal through the editor, it's always connected, and the node receives callbacks, even if the state should be inactive. We don't want that to happen: only the active state should run code, otherwise we can introduce nasty bugs in our game (and that kills the purpose of the state pattern).

    What we're doing here is that when a state becomes active, it connects the signals it needs to work properly. As soon as another state becomes active, it disconnects all its signals. That way, each state can only receive signal callbacks when it's active.