public abstract class AbstractSprite extends java.lang.Object implements Sprite
In essence, a Sprite decorates a TransformableContent object, providing it with additional capabilities.
Note: We don't immediately delegate since the content and the location/rotation/scale may change at any time and in any order. Instead, we set the location/rotation/scale before rendering.
| Constructor and Description |
|---|
AbstractSprite()
Default Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
java.awt.geom.Rectangle2D |
getBounds2D()
Returns a high precision bounding box of the
transformed Content.
|
java.awt.geom.Rectangle2D |
getBounds2D(boolean ofTransformed)
Returns a high precision bounding box of the Content
either before or after it is transformed.
|
abstract void |
handleTick(int time)
Handle a tick event
(required by MetronomeListener).
|
boolean |
intersects(Sprite s)
Given their current state, does the bounding box of this
Sprite intersect the bounding box of the given Sprite?
|
void |
render(java.awt.Graphics g)
Render this Sprite.
|
void |
setLocation(double x,
double y)
Set the location (on the Stage) of the Sprite.
|
void |
setRotation(double r)
Set the rotation angle (the Sprite will rotate
around its midpoint).
|
void |
setRotation(double r,
double x,
double y)
Set the rotation angle and point to rotate around.
|
void |
setScale(double s)
Set the scaling (enlargement, reduction) of the Sprite.
|
void |
setScale(double sx,
double sy)
Set the scaling (enlargement, reduction) of the Sprite.
|
void |
setVisible(boolean v)
Set the visibility of this Sprite.
|
public java.awt.geom.Rectangle2D getBounds2D(boolean ofTransformed)
getBounds2D in interface TransformableContentofTransformed - true to get the bounds of the transformed contentpublic java.awt.geom.Rectangle2D getBounds2D()
public abstract void handleTick(int time)
handleTick in interface MetronomeListenertime - The current time (in milliseconds)public boolean intersects(Sprite s)
s - The other Spritepublic void render(java.awt.Graphics g)
render in interface SimpleContentg - The rendering engine to usepublic void setLocation(double x,
double y)
setLocation in interface TransformableContentx - The horizontal locationy - The vertical locationpublic void setRotation(double r,
double x,
double y)
setRotation in interface TransformableContentr - The new rotation anglex - The x-coordinate of the point to rotate aroundy - The y-coordinate of the point to rotate aroundpublic void setRotation(double r)
r - The new rotation anglepublic void setScale(double sx,
double sy)
setScale in interface TransformableContentsx - The scale in the x-dimensionsy - The scale in the y-dimensionpublic void setScale(double s)
s - The new scalepublic void setVisible(boolean v)
v - true for visible, false for invisible