Hi, I'm a new member in the java game's world and my intent is to write my first game: a "shooting game".I wanna give an animation to the enemy sprites, I've seen the "Animation.java" class in the "New Riders Developing Games In Java" document and I would like to know if is good or if there are best ways to build animation.

its a rather common way and good to use. but for my taste theres no real reason to create a class(AnimFrame) for only holding two attributes.but i would keep a two class system if you plan to realize some advanced features:i usually need several different ways of doing an animation, e.g. backwards, looped-ones orwhatever. so i have an AnimationStrip class holding the images and an Animator class doing thecounting stuff for advancing the frames

Im not really sure what this class is for. All it seems to do is return an image based on a time,it does nothing to actually draw the image that I can see.

A class per image seems a waste to me, too. All you need is an array of images and an array of update times in your sprite class. But I dont see much harm in it either if it makes it easier for you to personally organize.

**shrug**

It doesnt seem to address the more interesting and bigger issues-- which is how you are organizing frame rendering. Are you doing entire frame or dirty rectangle? Are you using active or passive rendering? Are you page flipping? Are you using VolatileImage for your sprite data and if so what are you doing abotu loss of the volatile buffer?

Got a question about Java and game programming? Just new to the Java Game Development Community? Try my FAQ. Its likely you'll learn something!

hmmm, i really think such a container for an animation sequence is a good idea. although there arent much ideas in mesina's code implemented yet, you could imagine lots of it. because he mentioned to be new to java gaming i assume he will use perhpas double buffering (which hasnt to be part of this class) and only adds single frames to the arraylist. so the class takes control over the indexing stuff, perhaps even with my idea of several indexingstrategies. this can really be a pain to implement in the sprite class itself. moreover its a good place to watch, when the animation really ended, dependend onwhich animation strategy you chose and to notify the owner. e.g. a glowing star is a set of few frames which show a point getting brighter. the strategy could be to animate it once forward and then once backward,after that something happens (stopping, removing, changing the animation, whatever).

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org