org.jrabbit.standard.game.objects
Class Sprite

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.Sprite
All Implemented Interfaces:
Renderable, DynamicSkinned, Skin, Skinned, GLTransform, Colored, Dimensioned, GLGroupTransformed, Located, Rotated, Scaled, ScreenObject, Visible

public class Sprite
extends BaseSprite
implements DynamicSkinned

Sprite provides a simple implementation of BaseSprite that uses a Skin for rendering and maintaining its dimensions. This Skin is fully dynamic, and can be redefined at any time.

Author:
Chris Molini

Field Summary
protected  Skin skin
          The Skin used to render the Sprite.
 
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
Sprite(Skin skin)
          Creates a Sprite that utilizes the indicated Skin.
Sprite(java.lang.String reference)
          Creates a Sprite with an ImageSkin that attempts to retrieve the indicated Image from the ImageCache.
 
Method Summary
 void draw()
          Renders the active skin.
 float height()
          Accesses the dimensions of the current Skin used by the Sprite.
 void setSkin(Skin skin)
          Redefines the active Skin being used.
 Skin skin()
          Accesses the current Skin.
 float width()
          Accesses the dimensions of the current Skin used by the Sprite.
 
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
 
Methods inherited from interface org.jrabbit.base.core.types.Renderable
render
 

Field Detail

skin

protected Skin skin
The Skin used to render the Sprite.

Constructor Detail

Sprite

public Sprite(java.lang.String reference)
Creates a Sprite with an ImageSkin that attempts to retrieve the indicated Image from the ImageCache.

Parameters:
reference - The reference indicating the Image to use.

Sprite

public Sprite(Skin skin)
Creates a Sprite that utilizes the indicated Skin.

Parameters:
skin - The Skin to use.
Method Detail

skin

public Skin skin()
Accesses the current Skin.

Specified by:
skin in interface Skinned
Returns:
The Skin being used to render and determine the Sprite's dimensions.

setSkin

public void setSkin(Skin skin)
Redefines the active Skin being used.

Specified by:
setSkin in interface DynamicSkinned
Parameters:
skin - The Skin for the Sprite to use.

width

public float width()
Accesses the dimensions of the current Skin used by the Sprite.

Specified by:
width in interface Dimensioned
Returns:
The width of the Skin.

height

public float height()
Accesses the dimensions of the current Skin used by the Sprite.

Specified by:
height in interface Dimensioned
Returns:
The height of the Skin.

draw

public void draw()
Renders the active skin.

Specified by:
draw in class BaseSprite