org.jrabbit.standard.game.objects.specialized
Class AnimatedSprite

java.lang.Object
  extended by org.jrabbit.standard.game.objects.base.Spatial
      extended by org.jrabbit.standard.game.objects.base.BaseSprite
          extended by org.jrabbit.standard.game.objects.specialized.AnimatedSprite
All Implemented Interfaces:
Renderable, Updateable, AnimationListener, Skin, GLTransform, Colored, Dimensioned, GLGroupTransformed, Located, Rotated, Scaled, ScreenObject, Visible

public class AnimatedSprite
extends BaseSprite
implements Updateable, AnimationListener

An AnimatedSprite is an Updateable BaseSprite that uses an AnimatedSkin to render itself. NOTE: This AnimatedSprite will not change over time unless its update(int) method is repeatedly called.

Author:
Chris Molini

Field Summary
protected  AnimatedSkin animation
          The currently active Animation.
 
Fields inherited from class org.jrabbit.standard.game.objects.base.BaseSprite
color, screenCoords, transforms, visible
 
Fields inherited from class org.jrabbit.standard.game.objects.base.Spatial
location, rotation, scalar
 
Constructor Summary
AnimatedSprite(AnimatedSkin animation)
          Creates an AnimatedSprite with the indicated AnimatedSkin.
 
Method Summary
 AnimatedSkin animation()
          Accesses the active animation.
 void draw()
          Renders the active AnimatedSkin.
 float height()
          Accesses the dimensions of the active AnimatedSkin.
 void onCycleEnd(int cycle)
          Alerts the AnimatedSprite that the AnimatedSkin has reached the end of a cycle.
 void onFrame(int cycle, int frame)
          Alerts the AnimatedSprite that a new frame has been selected.
 void setAnimation(AnimatedSkin animation)
          Redefines the active animation.
 void update(int delta)
          Updates the AnimatedSkin.
 float width()
          Accesses the dimensions of the active AnimatedSkin.
 
Methods inherited from class org.jrabbit.standard.game.objects.base.BaseSprite
bind, color, onscreen, release, render, screenCoords, setVisible, shouldRender, transforms, visible
 
Methods inherited from class org.jrabbit.standard.game.objects.base.Spatial
location, rotation, scalar, scaledDiameter, scaledHeight, scaledWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

animation

protected AnimatedSkin animation
The currently active Animation.

Constructor Detail

AnimatedSprite

public AnimatedSprite(AnimatedSkin animation)
Creates an AnimatedSprite with the indicated AnimatedSkin.

Parameters:
animation - The AnimatedSkin to use.
Method Detail

animation

public AnimatedSkin animation()
Accesses the active animation.

Returns:
The currently active AnimatedSkin.

setAnimation

public void setAnimation(AnimatedSkin animation)
Redefines the active animation.

Parameters:
animation - The new AnimatedSkin to use.

onFrame

public void onFrame(int cycle,
                    int frame)
Alerts the AnimatedSprite that a new frame has been selected. NOTE: By default, this method does nothing.

Specified by:
onFrame in interface AnimationListener
Parameters:
cycle - The cycle of animation currently active.
frame - The new frame of the current cycle.

onCycleEnd

public void onCycleEnd(int cycle)
Alerts the AnimatedSprite that the AnimatedSkin has reached the end of a cycle. NOTE: By default, this method does nothing.

Specified by:
onCycleEnd in interface AnimationListener
Parameters:
cycle - The cycle of animation that has ended.

width

public float width()
Accesses the dimensions of the active AnimatedSkin.

Specified by:
width in interface Dimensioned
Returns:
The width of the current frame of animation.

height

public float height()
Accesses the dimensions of the active AnimatedSkin.

Specified by:
height in interface Dimensioned
Returns:
The height of the current frame of animation.

update

public void update(int delta)
Updates the AnimatedSkin.

Specified by:
update in interface Updateable
Parameters:
delta - The number of microseconds that have passed.

draw

public void draw()
Renders the active AnimatedSkin.

Specified by:
draw in class BaseSprite