libgdx/libgdx — pull request #2278 by nooone (2014-08-28 20:28:22+00:00)
Title: FSM changeState possible with null.

I have added a `null` check to `DefaultStateMachine.changeState(...)`. It is the only place where this check is not performed yet. That way it is possible to exit the "last" state via a state change to `null`.

In my case I have an enemy class that switches to from `CombatState` to `DieState`. After the dying animation is completed, I switch to `DeadState`. Now the enemy is lying on the ground. I want it to "rot" and disappear after a few seconds. So I got a counter that starts in `DeadState.enter()`. In `DeadState.exit()` I call `enemy.dispose()` to completely remove it from the game. There isn't really a `State` I could switch to at this point. That's why I want to perform a `changeState(null)` which results in an `exit()`.