|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.jpemartin.jgt.DrawAnim
public class DrawAnim
Loads images, then displays an animation by looping through the images. The image can be in any format that Java can load; I recommend png. The loading will work for files on disk, a jar file, or files on a web server running an applet. Use relative names like "player.png" or "images/laser.png", not "c:\program files\java\my images\cool picture.png" If you have several objects using the same animation, it is more efficient to create one DrawAnim and then clone() it rather than creating several: the clone shares data with the original so you save on memory, and the images are loaded only once so you save on initialization time.
| Constructor Summary | |
|---|---|
DrawAnim(java.util.Collection imageNames,
int delay)
An animation that loops through the given images, each image is displayed "delay" times (or once if delay<1). |
|
DrawAnim(java.util.Collection imageNames,
int delay,
boolean keyed)
An animation that loops through the given images, each image is displayed "delay" times (or once if delay<1). |
|
DrawAnim(java.lang.String imageName)
An animation that displays the given image. |
|
DrawAnim(java.lang.String imageName,
boolean keyed)
An animation that displays the given image. |
|
| Method Summary | |
|---|---|
java.lang.Object |
clone()
creates a clone of this object. |
void |
draw(java.awt.Graphics g,
int x,
int y)
draw one frame of the animation at the specified position |
int |
getHeight()
|
int |
getLoopCount()
return the number of times every frame in the animation was drawn |
int |
getWidth()
|
void |
reset()
back to original state (images loaded, beginning of anim loop). |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DrawAnim(java.lang.String imageName)
throws java.io.IOException
java.io.IOException
public DrawAnim(java.lang.String imageName,
boolean keyed)
throws java.io.IOException
java.io.IOException
public DrawAnim(java.util.Collection imageNames,
int delay)
throws java.io.IOException
java.io.IOException
public DrawAnim(java.util.Collection imageNames,
int delay,
boolean keyed)
throws java.io.IOException
java.io.IOException| Method Detail |
|---|
public void reset()
public java.lang.Object clone()
throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedException
public void draw(java.awt.Graphics g,
int x,
int y)
draw in interface Drawablepublic int getWidth()
public int getHeight()
public int getLoopCount()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||