Book Image

JMonkeyEngine 3.0 Cookbook

By : Rickard Eden
Book Image

JMonkeyEngine 3.0 Cookbook

By: Rickard Eden

Overview of this book

Table of Contents (17 chapters)
jMonkeyEngine 3.0 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating an animation manager control


We will create a control that will handle the animations of a character. It will follow jMonkeyEngine's control pattern and extend AbstractControl. We won't actually use most of the functions of AbstractControl right away, but it's a neat way to offset some of the code from a possible Character class. It will also be easy to add functionalities later on.

How to do it...

To create a control that will handle the animations of a character, perform the following steps:

  1. Create a class called CharacterAnimationManager and have it extend AbstractControl. This class should also implement AnimEventListener, which AnimControl uses to tell our class when animations have finished playing.

  2. We're going to map Jaime's animations into an enum. This is so we don't have to do a lot of string comparisons. While we're at it, we'll add some basic logic to the enum as well. The name of the animation, whether the animation should loop or not, and the time AnimControl should take...