In version 1.4 of the Java 2 SDK, Sun Microsystems introduced support for full-screen exclusive mode, an operating system feature that lets programs obtain exclusive access to and render their output to the entire screen, which results in high-performance graphics. (Microsoft Windows implements full-screen exclusive mode via its DirectX technology, for example.) This Java Fun and Games installment reveals this support in the context of an "under the sea" application and its animation engine.
This article first introduces you to the "under the sea" (UTS) application, where you learn about the application's image and audio resources. The article next explores the application's architecture in terms of the application class, the animation and audio classes, and the resource-loader class. You next tour the animation engine's engine class, animation and audio interfaces, and exception classes. In closing, this article focuses on how to deploy the application.
| Note |
|---|
| Unlike most of the previous Java Fun and Games installments, which I wrote from the perspective of J2SE 1.4, this installment requires Java SE 5.0. For thorough coverage of Java's support for full-screen exclusive mode, consult the Java Tutorial. |
I've created a UTS application that works with the animation engine to animate underwater sea life over the entire screen. This application's source code, audio/image resource, and miscellaneous files can be downloaded from Resources.
This figure presents a single animation frame. This frame reveals a suitable background, an animated angel fish, two instances of an animated tiger barb, two instances of an animated zebra fish, two instances of an animated plant, and three instances of an animated bubble sequence.
The figure shows various graphics images that I've combined into a somewhat realistic underwater scene: I created the background image with the Terragen scenery generator and enhanced the resulting image to achieve a bluish haze in the distance; the angel fish, tiger barb, and zebra fish images were made available to me courtesy of Dave Sutton at Sevenoaks Art; and the bubbles/plants images are my own creations.
Each type of fish requires 16 images (8 for moving left to right, and 8 for moving right to left), the bubble sequence requires
8 images, and the plant animation requires 3 images. The background image and one other image (used for hiding the mouse cursor)
round out the image resources. These image resources are organized into gif files that are stored in a hierarchical resource
directory structure, rooted in the images directory:
images
angelfish
lfish1.gif
lfish2.gif
lfish3.gif
lfish4.gif
lfish5.gif
lfish6.gif
lfish7.gif
lfish8.gif
rfish1.gif
rfish2.gif
rfish3.gif
rfish4.gif
rfish5.gif
rfish6.gif
rfish7.gif
rfish8.gif
bubbles
bubbles1.gif
bubbles2.gif
bubbles3.gif
bubbles4.gif
bubbles5.gif
bubbles6.gif
bubbles7.gif
bubbles8.gif
misc
background.gif
white.gif
plant
plant1.gif
plant2.gif
plant3.gif
tigerbarb
lfish1.gif
lfish2.gif
lfish3.gif
lfish4.gif
lfish5.gif
lfish6.gif
lfish7.gif
lfish8.gif
rfish1.gif
rfish2.gif
rfish3.gif
rfish4.gif
rfish5.gif
rfish6.gif
rfish7.gif
rfish8.gif
zebrafish
lfish1.gif
lfish2.gif
lfish3.gif
lfish4.gif
lfish5.gif
lfish6.gif
lfish7.gif
lfish8.gif
rfish1.gif
rfish2.gif
rfish3.gif
rfish4.gif
rfish5.gif
rfish6.gif
rfish7.gif
rfish8.gif
Along with presenting animations, the UTS application is capable of playing an audio clip (in the Sun AU format) to add realism. This audio clip can be toggled off and on by pressing the "A" key.
| Subject |
|
|
UTSBy Anonymous on January 14, 2010, 2:59 amNice application and another great resource. You can also try another good tool for animated pictures with excellent results. Gif Animated Pictures
Reply | Read entire comment
View all comments