Package games.stendhal.client.sprite
Class AnimatedSprite
java.lang.Object
games.stendhal.client.sprite.AnimatedSprite
- All Implemented Interfaces:
Sprite
- Direct Known Subclasses:
SequenceSprite
This is a sprite that transparently animates itself when drawn.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAnimatedSprite(Sprite[] frames, int delay, boolean animating) Create an animated sprite from a set of frame sprites. -
Method Summary
Modifier and TypeMethodDescriptioncreateRegion(int x, int y, int width, int height, Object ref) Create a sub-region of this sprite.voidDraw the sprite onto the graphics context provided.voidDraws the image.intGet the height of the drawn sprite.Get the sprite reference.intgetWidth()Get the width of the drawn sprite.voidreset(int index) Reset the animation back to specified frame, and reset the next frame time.voidstart()Start the sprite animating.voidstop()Stop the sprite animating.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface games.stendhal.client.sprite.Sprite
isConstant
-
Field Details
-
delays
protected int[] delaysThe [minimum] frame durations. -
frames
The frame sprites. -
lastUpdate
protected long lastUpdateThe time of the last update. -
loop
protected boolean loopWhether to loop after last frame. -
sprite
The current sprite.
-
-
Constructor Details
-
AnimatedSprite
Create an animated sprite from a set of frame sprites. NOTE: The array of frames passed is not copied, and must not be modified while this instance exists (unless you are sure you know what you are doing).- Parameters:
frames- The frames to animate.delay- The minimum delay between frames (in ms).animating- If animation is enabled.- Throws:
IllegalArgumentException- If less than one frame is given, or the delay is < 0.
-
-
Method Details
-
reset
public void reset(int index) Reset the animation back to specified frame, and reset the next frame time.- Parameters:
index- the default index
-
start
public void start()Start the sprite animating.- See Also:
-
stop
public void stop()Stop the sprite animating. This does not change the current frame.- See Also:
-
createRegion
Create a sub-region of this sprite. NOTE: This does not use caching.- Specified by:
createRegionin interfaceSprite- Parameters:
x- The starting X coordinate.y- The starting Y coordinate.width- The region width.height- The region height.ref- The sprite reference.- Returns:
- A new sprite.
-
draw
Draw the sprite onto the graphics context provided. -
draw
Draws the image. -
getHeight
public int getHeight()Get the height of the drawn sprite. -
getReference
Get the sprite reference. This identifier is an externally opaque object that implements equals() and hashCode() to uniquely/repeatably reference a keyed sprite.- Specified by:
getReferencein interfaceSprite- Returns:
- The reference identifier, or
nullif not referencable.
-
getWidth
public int getWidth()Get the width of the drawn sprite.
-