I have a problem.
There is a character with many different animations (running in different directions, standing, jumping, aiming, shooting, etc). In most cases there is condition that when no key is pressed, we set standing animation. Also there are many private variables which control separate parts of animation (e.g. when we press Space - jumping animation is playing, and sprite's 8-direction movement is changed to Bullet movement).
Problem is that I can't set every animation separately, because variables, keys and their inversion, overlap and interfere with each other...
Suggest please right scheme, where sprite with many animations works properly and variables don't interfere with each other.
Develop games in your browser. Powerful, performant & highly capable.
Perhaps a finite state automaton?
They're easy to do with matrixes, though I've even given some thought on making this a behavior.
I made this thing
Edit: the URL >_<
Shift to jump, space to shoot, touch the ground again to go back to the first state
Shows a really simple state machine. 3 states, stuffed in the matrix.
On exit, state 1 goes to 2, 2 goes to 3, 3 goes to 1.
Given its so simple, one could have ignored the matrix and set the state directly in the event.
I'm thinking it could get uncomfortable with during, entry and exit conditions and many possible exits and entries for each state, so a behavior would be comfortable.
I'll look into it.
use of sub animations and/or groups to disable states might be useful to you.