Java Reference
In-Depth Information
C H A P T E R 7
■ ■ ■
Effect: Animated Image Sequences
Not all animations in an application are dynamic. It is often desirable to create the animations in a
dedicated tool and then play the animation in the app. JavaFX has good support for video, for example,
but sometimes video is too heavy of a solution. Or perhaps you want to have an animation sequence
with partial transparency or be able to specify exactly which frames of the animation are visible when. In
these cases, animating a sequence of image files can produce desirable results, and as a bonus, most
animation software supports exporting image sequences directly.
This chapter discusses strategies for creating images and displaying the sequence as an animation
in a JavaFX scene. By displaying one image at a time an animation will be created, much like an old film
movie where each frame is a picture on the filmstrip. This will be implemented using a few core JavaFX
classes, such as Image and ImageView . The number of images that can be used to create animations like
this is surprisingly high, but some effort must be made to do this without ruining the performance of
your application. But before we get to the code, let's first discuss how to create the images.
Creating Images
There are excellent tools available for creating animations, and you should feel free to use any tool you
are comfortable with. Some are better suited for 2D animations, such as Adobe's After Effects, and other
tools are better at 3D. For 3D I can't recommend Blender enough. The learning curve is amazingly steep,
but after 20 hours or so you will find yourself able to create any shape you can think of. You will also find
video tutorials for all animation tools online, and I find this a good way to learn. Conduct a web search
for “Blender tutorial videos,” take your pick from the results, and start following along. And check out
the Blender web site at , which contains documentation and
videos to assist you.
Figure 7-1 shows a Blender project set up to create an animation. The plethora of buttons on the
screen hints at Blender's power and learning curve.
Search WWH ::

Custom Search