public interface SpriteAnimated extends Sprite, Animator
SpriteAnimated is an extended sprite that allows to play it using Animation
. It works like a sprite excepted
that it renders only a part of it (current Animator
frame).
Animation
contains the first/last frame and the animation speed, considering the main first frame is on the
top-left sprite surface, and the last frame is on the down-right sprite surface, reading it from left to right.
The first frame number is Animation.MINIMUM_FRAME
.
Example:
// Load final SpriteAnimated animation = Drawable.loadSpriteAnimated(Media.get("animation.png"), 7, 1); animation.load(false); final Animation anim = Anim.createAnimation(4, 6, 0.125, false, true); animation.play(anim); // Update (in loop) animation.updateAnimation(extrp); // Render (in loop) animation.setMirror(false); animation.render(g, 160, 300); animation.setMirror(true); animation.render(g, 200, 300);
Modifier and Type | Method and Description |
---|---|
ImageBuffer |
getFrame(int frame)
Get the representative surface of a frame.
|
int |
getFrameHeight()
Get current frame height.
|
int |
getFrameHeightOriginal()
Get original frame height.
|
int |
getFramesHorizontal()
Get the number of horizontal frames.
|
int |
getFramesNumber()
Get the number of frames.
|
int |
getFramesVertical()
Get the number of vertical frames.
|
int |
getFrameWidth()
Get current frame width.
|
int |
getFrameWidthOriginal()
Get original frame width.
|
void |
render(Graphic g,
int frame,
int x,
int y)
Render a specific frame on graphic output at specified coordinates.
|
void |
setMirror(boolean mirror)
Set the mirror state.
|
filter, flipHorizontal, flipVertical, getHeightOriginal, getSurface, getWidthOriginal, load, render, rotate, scale, setAlpha, setTransparency, stretch
getHeight, getWidth
getAnimState, getFrame, getFrameAnim, play, setAnimSpeed, setFrame, stopAnimation, updateAnimation
void render(Graphic g, int frame, int x, int y)
g
- The graphic output.frame
- The frame to render (>= Animation.MINIMUM_FRAME
).x
- The horizontal location.y
- The vertical location.void setMirror(boolean mirror)
mirror
- Set true
if it is a mirror rendering (rendering is flipped), false
if
normal.int getFramesHorizontal()
int getFramesVertical()
int getFramesNumber()
int getFrameWidth()
int getFrameHeight()
int getFrameWidthOriginal()
int getFrameHeightOriginal()
ImageBuffer getFrame(int frame)
frame
- The frame to get (>= Animation.MINIMUM_FRAME
).