Game Development Reference
In-Depth Information
How it works...
The implementation relies on the listener pattern where this control receives a notification
of user actions from an external input class. In this project, we have a separate class that
controls the character.
This onAnimCycleDone method is called by the AnimControl method when an an-
imation has finished with one cycle (both looping and non-looping animations). Normally,
when an animation ends, we'll want to switch to the idle animation to stop it from freezing.
When JumpStart is finished, however, the character is most likely in midair and thus
switches to a suitable looping animation. The inAir Boolean is used so the class knows it
should start checking for when the character lands again.
Depending on the size of a project, the control class for the character and this animation-
managing class might be merged into one. This should make some things easier, while the
class itself might get bulky as more functions are implemented.
The controlUpdate class is called automatically with every tick, and here we can see
whether the character is still airborne. In this implementation, BetterCharacterCon-
trol is used, and it has a method to see whether it is on ground. Jaime has a JumpEnd
animation, but idle seems to work better with some blending.
Search WWH ::




Custom Search