Everything is set up, but if you run the application now, the model is stuck in its idle pose. Use what you learned in the previous chapter about the AnalogListener
and ActionListener
, and configure the Space bar to make the character walk toward you gradually, while playing the walk animation!
Write an
ActionListener
that waits for theMAPPING_WALK
trigger, and then tests whether the key is pressed or up. If the key is pressed, test ifANI_WALK
is still playing on the animation channel; if it isn't, playANI_WALK
again. If the key is not pressed, playANI_IDLE
again.private ActionListener actionListener = new ActionListener() { public void onAction(String name, boolean isPressed, float tpf) { if (name.equals(MAPPING_WALK) && isPressed) { if (!channel.getAnimationName().equals(ANI_WALK)) { channel.setAnim(ANI_WALK); } } if (name.equals(MAPPING_WALK) && !isPressed) { channel.setAnim(ANI_IDLE...