In this recipe, we'll show how the jumping animation can be handled in the animation manager control from previous recipes. Why does this require its own recipe? Animation-wise, jumping is usually a set of sequenced animations. If we look at Jaime, for example, there's JumpStart
, Jumping
, and JumpEnd
. Normally, sequenced animations can be handled in the onAnimCycleDone
method; when one animation ends, it can trigger the next. Jumping is different though since the middle jumping animation is indefinite and is on a loop. How long it plays depends on how long the character is in the air, which is driven by the gameplay or its physics.
You can handle jumping animations by performing the following steps:
For this, we'll need to add two more Booleans to our animation control:
jumpStarted
andinAir
.We trigger the first part of the animation in the
onAction
method, as shown in the following code. ThejumpStarted
Boolean is used to let the class know that other...