Hour 24. Creating Animation

Whether you are reading this tutorial in 24 one-hour sessions or a day-long-bring-me-more-coffee-can't-feel-my-hand-are-you-going-to-finish-that-doughnut marathon, you deserve something for making it this far. Unfortunately, Sams Publishing declined my request to buy you a pony, so the best I can offer as a reward is the most entertaining subject in the tutorial: animation. At this point, you have learned how to use text, fonts, color, lines, and polygons in your Java programs. For the last hour on Java's multimedia capabilities, and the last hour of the tutorial, you will learn how to display image files in GIF and JPEG formats in your programs and present them in animated sequences. The following topics will be covered:

  • Using Image objects to hold image files
  • Putting a series of images into an array
  • Cycling through an image array to produce animation
  • Using the drawImage() command
  • Establishing rules for the movement of an image