superwaba.ext.xplat.game
Class AnimatedSprite
java.lang.Object
|
+--superwaba.ext.xplat.game.Sprite
|
+--superwaba.ext.xplat.game.AnimatedSprite
- public class AnimatedSprite
- extends Sprite
Class implementing a game animated sprite.
This is a sprite that supports multiple images corresponding to a sprite animation
or sprite's different states.
- See Also:
Sprite
Field Summary |
protected int |
curFrame
Current selected frame. |
protected Image[] |
frames
Different sprite's frames, if several Image frames have been provided. |
protected int[] |
halfHeights
Images half width/height dimensions. |
protected int[] |
halfWidths
Images half width/height dimensions. |
int[] |
heights
Images width/height dimensions. |
int[] |
widths
Images width/height dimensions. |
Fields inherited from class superwaba.ext.xplat.game.Sprite |
background,
bgGfx,
bgX,
bgY,
centerX,
centerY,
doClip,
drawOp,
gfx,
halfHeight,
halfWidth,
height,
image,
INVALID,
regionMaxx,
regionMaxy,
regionMinx,
regionMiny,
screenErased,
speed,
surface,
transColor,
width |
Method Summary |
void |
setFrame(int frame)
Set the sprite's current frame. |
void |
show()
Draw the sprite's current frame at it's current
position using the defined drawOp. |
widths
public int[] widths
- Images width/height dimensions. READ-ONLY attributes.
heights
public int[] heights
- Images width/height dimensions. READ-ONLY attributes.
halfWidths
protected int[] halfWidths
- Images half width/height dimensions. READ-ONLY attributes.
halfHeights
protected int[] halfHeights
- Images half width/height dimensions. READ-ONLY attributes.
frames
protected Image[] frames
- Different sprite's frames, if several Image frames have been provided.
curFrame
protected int curFrame
- Current selected frame.
AnimatedSprite
protected AnimatedSprite(Image[] frames,
Color transColor,
boolean saveBckgd,
Rect region)
- AnimatedSprite constructor.
- Parameters:
frames
- sprite different state images.transColor
- sprite's transparency color or null if none
(needed in DRAW_SPRITE mode to keep the current background).saveBckgd
- true if the background should be saved each time the sprite
is drawn to restore it once the sprite moves.region
- defines the sprite valid area.
If null, a default region
is set to prevent the largest sprite frame to leave even partially the screen.
AnimatedSprite
protected AnimatedSprite(Image frames,
int frameWidth,
Color transColor,
boolean saveBckgd,
Rect region)
- AnimatedSprite constructor.
- Parameters:
frames
- sprite different state frames in multi-frame BMP format.frameWidth
- width in pixels of one frame.transColor
- sprite's transparency color or null if none
(needed in DRAW_SPRITE mode to keep the current background).saveBckgd
- true if the background should be saved each time the sprite
is drawn to restore it once the sprite moves.region
- defines the sprite valid area.
If null, a default region
is set to prevent the largest sprite frame to leave even partially the screen.- See Also:
Gif2Bmps
show
public void show()
- Draw the sprite's current frame at it's current
position using the defined drawOp.
If the Sprite has been created with enabled background saving
(usefull only when the screen is not cleared before the new frame display)
the previously stored background will be restored first and the
sprite is displayed in a second step.
- Overrides:
- show in class Sprite
- See Also:
Sprite
setFrame
public void setFrame(int frame)
- Set the sprite's current frame.
- Parameters:
frame
- number to use for next sprite processing