game.graphics.sprite
Class CAnimatedSprite
java.lang.Object
game.physics.CStaticShape
game.physics.CDynamicShape
game.graphics.sprite.CAnimatedSprite
- All Implemented Interfaces:
- ICriticalObject, IGraphicObject
public class CAnimatedSprite
- extends CDynamicShape
- implements IGraphicObject, ICriticalObject
This class implements time indexed animated sprites. Animation can be reversed at any time.
- Author:
- seb
Method Summary |
void |
animate(float dt)
Animates the sprite. |
protected void |
bounceOnGameRect()
Same as inherited function. |
void |
draw(java.awt.Graphics g)
Simply draws the current image. |
private float[] |
generateTimeIntervals(float fFrameTime)
Generates an array of equal time intervals. |
private void |
initTimeIntervals(float[] aTimeIntervals)
|
boolean |
isCritical()
|
private void |
splitSprites(java.awt.Image img)
Takes an Image and splits it in a sprite array. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
m_aSprites
private java.awt.image.BufferedImage[] m_aSprites
m_aTimeIntervals
private float[] m_aTimeIntervals
m_index
private int m_index
m_t
private float m_t
m_isCycling
private final boolean m_isCycling
- See Also:
- Constant Field Values
m_bReverseAnimation
private boolean m_bReverseAnimation
CAnimatedSprite
public CAnimatedSprite(IGameDisplay gameRect,
CBoundingBox box,
CVector2D velocity,
java.awt.Image imgSprites,
float[] aFrameTimes)
- Parameters:
gameRect
- : the rectangle the sprite will evolve inbox
- : the sprite's bounding box (can be different than image size)velocity
- : sprite's initial velocityimgSprites
- : the sprite's image arrayaFrameTimes
- : the frame time indexes array
CAnimatedSprite
public CAnimatedSprite(IGameDisplay gameRect,
CBoundingBox box,
CVector2D velocity,
java.awt.Image imgSprites,
float fFrameTime)
- Fixed frame time version of the above.
- Parameters:
fFrameTime
- : the constant frame time.
splitSprites
private final void splitSprites(java.awt.Image img)
- Takes an Image and splits it in a sprite array.
Uses a CImageProcessor to split the Image.
- Parameters:
img
- the image containing the sprite animation- See Also:
CImageProcessor
generateTimeIntervals
private final float[] generateTimeIntervals(float fFrameTime)
- Generates an array of equal time intervals.
- Parameters:
fFrameTime
- the fixed time interval
- Returns:
- an array of fixed time intervals
initTimeIntervals
private final void initTimeIntervals(float[] aTimeIntervals)
animate
public final void animate(float dt)
- Animates the sprite. Contains the major part of the magic.
- Specified by:
animate
in interface IGraphicObject
- Overrides:
animate
in class CDynamicShape
- Parameters:
dt
- : the amount of time to advance of.
draw
public void draw(java.awt.Graphics g)
- Simply draws the current image.
- Specified by:
draw
in interface IGraphicObject
bounceOnGameRect
protected void bounceOnGameRect()
- Same as inherited function. Except that it reverses the animation for demonstration purpose.
- Overrides:
bounceOnGameRect
in class CDynamicShape
isCritical
public boolean isCritical()
- Specified by:
isCritical
in interface ICriticalObject