public class AnimatedImage extends ImageBase
ImagePack
is that the class automatically
tracks the time that passed since the last draw call and
changes the image automatically if the requested animatedImage
time has passed.Modifier and Type | Field and Description |
---|---|
protected ImagePack |
images
The images comprising the animatedImage.
|
protected long |
lastRun
Last change of the sprite.
|
protected int |
time
Time between two frames in milliseconds.
|
imageCache
Constructor and Description |
---|
AnimatedImage(int time,
boolean wrapAround,
ImagePack images)
Creates a new animatedImage object.
|
AnimatedImage(int time,
boolean wrapAround,
java.lang.String path,
java.lang.String... fileNames)
Convenience constructor that creates the image pack for the
caller to make usage easier.
|
AnimatedImage(int time,
ImagePack images)
Creates a new object.
|
AnimatedImage(int time,
int number,
java.lang.String imageFilePath)
Convenience constructor that creates the striped image for the
caller to make usage easier.
|
AnimatedImage(int time,
java.lang.String path,
java.lang.String... fileNames)
Convenience constructor that creates the image pack for the
caller to make usage easier.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(java.awt.Graphics g,
java.awt.Point position,
java.awt.image.ImageObserver observer)
Draw the image at the given position.
|
java.awt.Dimension |
getDimension()
Dimension of the image.
|
ImagePack |
getImages()
Returns the images comprising the animatedImage.
|
AnimatedImage |
getSubAnimation(int start,
int end)
Returns an animation that contains the images from this animation
starting with picture
start (inclusive) up to picture
end (exclusive). |
int |
getTime()
Returns the time before the image is changed.
|
loadImage, loadImage, toBufferedImage
protected ImagePack images
protected long lastRun
protected int time
public AnimatedImage(int time, boolean wrapAround, ImagePack images)
time
- the time one image is shown in millisecondswrapAround
- if set to true
the animation cycles infinitely
through the images. If set to false
it stops at
the last image.images
- the images comprising the animatedImagepublic AnimatedImage(int time, boolean wrapAround, java.lang.String path, java.lang.String... fileNames)
time
- the time one image is shown in millisecondswrapAround
- if set to true
the animation cycles infinitely
through the images. If set to false
it stops at
the last image.path
- path to the imagefileNames
- names of the files to be loadedpublic AnimatedImage(int time, ImagePack images)
time
- the time one image is shown in millisecondsimages
- the images comprising the animatedImagepublic AnimatedImage(int time, int number, java.lang.String imageFilePath)
time
- the time one image is shown in millisecondsnumber
- the number of elementsimageFilePath
- the striped imagepublic AnimatedImage(int time, java.lang.String path, java.lang.String... fileNames)
time
- the time one image is shown in millisecondspath
- path to the imagefileNames
- names of the files to be loadedpublic void draw(java.awt.Graphics g, java.awt.Point position, java.awt.image.ImageObserver observer)
ImageBase
public java.awt.Dimension getDimension()
ImageBase
getDimension
in class ImageBase
public ImagePack getImages()
public AnimatedImage getSubAnimation(int start, int end)
start
(inclusive) up to picture
end
(exclusive).start
- index of the first picture of the animationend
- index of the last picture (exclusive) of the animationpublic int getTime()