Using finite state machines to model player behaviour and animations.

Article by Hannah Farrugia . Posted on 22nd Jun 2020.   @Pyxish

image

One thing that's made adding new features really easy in Phaser is using finite-state machines to model behaviour.

In this article, Michael Kelly creates a state class in his project, to model the player's behaviour by assigning them a single "state" to be in. When the player is in a "state", they can "transition" to another state if a condition is met, which replaces the current state with a new one.
Almost every player animation transition can be backed by a state machine.

Read More