|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.newdawn.slick.Animation
public class Animation
A utility to hold and render animations
Constructor Summary | |
---|---|
Animation()
Create an empty animation |
|
Animation(boolean autoUpdate)
Create an empty animation |
|
Animation(Image[] frames,
int duration)
Create a new animation from a set of images |
|
Animation(Image[] frames,
int[] durations)
Create a new animation from a set of images |
|
Animation(Image[] frames,
int[] durations,
boolean autoUpdate)
Create a new animation from a set of images |
|
Animation(Image[] frames,
int duration,
boolean autoUpdate)
Create a new animation from a set of images |
|
Animation(SpriteSheet frames,
int duration)
Create a new animation based on the sprite from a sheet. |
|
Animation(SpriteSheet ss,
int[] frames,
int[] duration)
Creates a new Animation where each frame is a sub-image of SpriteSheet ss. |
|
Animation(SpriteSheet frames,
int x1,
int y1,
int x2,
int y2,
boolean horizontalScan,
int duration,
boolean autoUpdate)
Create a new animation based on a selection of sprites from a sheet |
Method Summary | |
---|---|
void |
addFrame(Image frame,
int duration)
Add animation frame to the animation |
void |
addFrame(int duration,
int x,
int y)
Add animation frame to the animation. |
Animation |
copy()
Create a copy of this animation. |
void |
draw()
Draw the animation to the screen |
void |
draw(float x,
float y)
Draw the animation at a specific location |
void |
draw(float x,
float y,
Color filter)
Draw the animation at a specific location |
void |
draw(float x,
float y,
float width,
float height)
Draw the animation |
void |
draw(float x,
float y,
float width,
float height,
Color col)
Draw the animation |
void |
drawFlash(float x,
float y,
float width,
float height)
Draw the animation |
void |
drawFlash(float x,
float y,
float width,
float height,
Color col)
Draw the animation |
Image |
getCurrentFrame()
Get the image associated with the current animation frame |
int |
getDuration(int index)
Get the duration of a particular frame |
int[] |
getDurations()
Get the durations of all the frames in this animation |
int |
getFrame()
Get the index of the current frame |
int |
getFrameCount()
Get the number of frames that are in the animation |
int |
getHeight()
Get the height of the current frame |
Image |
getImage(int index)
Get the image assocaited with a given frame index |
float |
getSpeed()
Returns the current speed of the animation. |
int |
getWidth()
Get the width of the current frame |
boolean |
isStopped()
Check if this animation has stopped (either explictly or because it's reached its target frame) |
void |
renderInUse(int x,
int y)
Render the appropriate frame when the spriteSheet backing this Animation is in use. |
void |
restart()
Restart the animation from the beginning |
void |
setAutoUpdate(boolean auto)
Indicate if this animation should automatically update based on the time between renders or if it should need updating via the update() method. |
void |
setCurrentFrame(int index)
Set the current frame to be rendered |
void |
setDuration(int index,
int duration)
Set the duration of the given frame |
void |
setLooping(boolean loop)
Indicate if this animation should loop or stop at the last frame |
void |
setPingPong(boolean pingPong)
Indicate if this animation should ping pong back and forth |
void |
setSpeed(float spd)
Adjust the overall speed of the animation. |
void |
start()
Start the animation playing again |
void |
stop()
Stop the animation |
void |
stopAt(int frameIndex)
Indicate the animation should stop when it reaches the specified frame index (note, not frame number but index in the animation |
java.lang.String |
toString()
|
void |
update(long delta)
Update the animation, note that this will have odd effects if auto update is also turned on |
void |
updateNoDraw()
Deprecated. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Animation()
public Animation(Image[] frames, int duration)
frames
- The images for the animation framesduration
- The duration to show each framepublic Animation(Image[] frames, int[] durations)
frames
- The images for the animation framesdurations
- The duration to show each framepublic Animation(boolean autoUpdate)
autoUpdate
- True if this animation should automatically update. This means that the
current frame will be caculated based on the time between renderspublic Animation(Image[] frames, int duration, boolean autoUpdate)
frames
- The images for the animation framesduration
- The duration to show each frameautoUpdate
- True if this animation should automatically update. This means that the
current frame will be caculated based on the time between renderspublic Animation(Image[] frames, int[] durations, boolean autoUpdate)
frames
- The images for the animation framesdurations
- The duration to show each frameautoUpdate
- True if this animation should automatically update. This means that the
current frame will be caculated based on the time between renderspublic Animation(SpriteSheet frames, int duration)
frames
- The sprite sheet containing the framesduration
- The duration each frame should be displayed forpublic Animation(SpriteSheet frames, int x1, int y1, int x2, int y2, boolean horizontalScan, int duration, boolean autoUpdate)
frames
- The sprite sheet containing the framesx1
- The x coordinate of the first sprite from the sheet to appear in the animationy1
- The y coordinate of the first sprite from the sheet to appear in the animationx2
- The x coordinate of the last sprite from the sheet to appear in the animationy2
- The y coordinate of the last sprite from the sheet to appear in the animationhorizontalScan
- True if the sprites are arranged in hoizontal scan lines. Otherwise
vertical is assumedduration
- The duration each frame should be displayed forautoUpdate
- True if this animation should automatically update based on the render timespublic Animation(SpriteSheet ss, int[] frames, int[] duration)
ss
- The SpriteSheet backing this animationframes
- An array of coordinates of sub-image locations for each frameduration
- The duration each frame should be displayed forMethod Detail |
---|
public void addFrame(int duration, int x, int y)
duration
- The duration to display the frame forx
- The x location of the frame on the SpriteSheety
- The y location of the frame on the spriteSheetpublic void setAutoUpdate(boolean auto)
auto
- True if this animation should automatically updatepublic void setPingPong(boolean pingPong)
pingPong
- True if the animation should ping pongpublic boolean isStopped()
stopAt
public void setSpeed(float spd)
spd
- The speed to run the animation. Default: 1.0public float getSpeed()
public void stop()
public void start()
public void restart()
public void addFrame(Image frame, int duration)
frame
- The image to display for the frameduration
- The duration to display the frame forpublic void draw()
public void draw(float x, float y)
draw
in interface Renderable
x
- The x position to draw the animation aty
- The y position to draw the animation atpublic void draw(float x, float y, Color filter)
x
- The x position to draw the animation aty
- The y position to draw the animation atfilter
- The filter to applypublic void draw(float x, float y, float width, float height)
x
- The x position to draw the animation aty
- The y position to draw the animation atwidth
- The width to draw the animation atheight
- The height to draw the animation atpublic void draw(float x, float y, float width, float height, Color col)
x
- The x position to draw the animation aty
- The y position to draw the animation atwidth
- The width to draw the animation atheight
- The height to draw the animation atcol
- The colour filter to usepublic void renderInUse(int x, int y)
x
- The x position to draw the animation aty
- The y position to draw the animation atpublic int getWidth()
public int getHeight()
public void drawFlash(float x, float y, float width, float height)
x
- The x position to draw the animation aty
- The y position to draw the animation atwidth
- The width to draw the animation atheight
- The height to draw the animation atpublic void drawFlash(float x, float y, float width, float height, Color col)
x
- The x position to draw the animation aty
- The y position to draw the animation atwidth
- The width to draw the animation atheight
- The height to draw the animation atcol
- The colour for the flashpublic void updateNoDraw()
public void update(long delta)
delta
- The amount of time thats passed since last updateautoUpdate
public int getFrame()
public void setCurrentFrame(int index)
index
- The index of the frame to renderedpublic Image getImage(int index)
index
- The index of the frame image to retrieve
public int getFrameCount()
public Image getCurrentFrame()
public void setLooping(boolean loop)
loop
- True if this animation should loop (true = default)public void stopAt(int frameIndex)
frameIndex
- The index of the frame to stop atpublic int getDuration(int index)
index
- The index of the given frame
public void setDuration(int index, int duration)
index
- The index of the given frameduration
- The duration in (ms) for the given framepublic int[] getDurations()
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public Animation copy()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |