[ Pobierz całość w formacie PDF ]
.The second ?in the tag is the number of the frame.For example, X3_7refers to the x value of the third animated object in the seventhkey frame.Now consider some of the advanced techniques and how they wereused in this example.This program provides the functionalityto create in-betweens and to use a background image.To keep theanimation from flickering, this code also uses the double-bufferedapproach to painting the image.The paths of the moving objects are specified in the HTML file,but they are filled in as suggested by the user with the InBetweenGeneratorobject.This object requires three values: the key locations,how many frames to produce between each set of key locations,and the type of motion between each key location.It then generatesan array of integers that represent the path that object traverses.To extend the InBetweenGeneratorobject to create another type of motion between end points, rewritethe interpolation() methodto include your new motion.All the equations in this method takea number between 0 and 1, and return a number between 0 and 1.However, if you want the object to overshoot the source or thedestination, you can create equations that produce values outsidethis range.Notice that a background image is an image that doesn't move anddoesn't change.To create a background for the animation, justmake the background image the first animated object.For more informationHere are some Web sites you can browse for more information about animations.The best collection of Java applets is Gamelan, and it has a page on animations.Its URL is as follows:http://www.gamelan.com/Gamelan.animation.htmlThe following sites have many links to animations.Viewing some of these sites can give you ideas for your animations:http://www.xm.com/cafe/AnimatePLUS/slideshow.htmlDescription of the slideshow applethttp://www.auburn.edu/~harshec/WWW/Cinema.htmlAn example of the slideshow in actionhttp://www-itg.lbl.gov/vbart/BART schedule animationhttp://www.intrinsa.com/personal/steve/ClickBoard/ClickBoard.htmlInteractive animationhttp://www.sealevelsoftware.com/sealevel/javademo.htmAnimation of falling raindropshttp://www.dimensionx.com/dnx/StreamingAnimation/index.htmlSmooth-loading animationhttp://www.geom.umn.edu/~daeron/apps/flag.htmlUnited States flag blowing in the windMore information about animation can be found at this URL:http://java.sun.com/people/avh/javaworld/animation/SummaryIn this chapter, we created the AnimationObjectinterface that simplifies design.This animation class was thenused to create moving text, to create a flip-book-style animation,to animate an image that contains frames, and to create a moving-imageanimation.Double buffering was used to eliminate flicker, andwe discussed the difference between the paint()and update() methods.Thefinal algorithms discussed were the use of in-betweens, backgroundimages, z-order numbers, and collision detection.What really launched Java into the spotlight for many people wasits capability to perform animations on the World Wide Web.Withthe release of Netscape 2.0, Java is not the only way to createanimations on Web pages.Increasingly, there are specialized programsthat help you create animations that can be visible on Web pages.One of these is Shockwave for Director, which enables you to createanimations in Director; Shockwave also allows the animations tobe viewed.VRML is a language that specifies three-dimensionalanimations by specifying the locations, objects, and a viewingpath.However, VRML currently requires special graphics hardwareto view.It seems, then, that Java is still the least expensiveway to create an animation.Contactreference@developer.com with questions or comments.Copyright 1998EarthWeb Inc., All rights reserved.PLEASE READ THE.Copyright 1998 Macmillan Computer Publishing.All rights reserved
[ Pobierz całość w formacie PDF ]