|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectframework.Sprite
public class Sprite
A Sprite object is an image or animation together with
a location. Sprites can be resized, flipped and rotated, although
this will have an effect on rendering speeds (rotation especially).
| Field Summary | |
|---|---|
protected double |
rotation
|
protected float |
x
|
protected float |
y
|
| Constructor Summary | |
|---|---|
Sprite()
|
|
Sprite(Animation animation)
|
|
Sprite(Animation animation,
float x,
float y)
|
|
Sprite(float x,
float y)
|
|
Sprite(Image image)
|
|
Sprite(Image image,
float x,
float y)
|
|
| Method Summary | |
|---|---|
void |
addRotation(double rotation)
|
void |
draw(Graphics2D g)
|
Animation |
getAnimation()
Get the current animation, if there is one. |
float |
getHeight()
|
Image |
getImage()
|
Point2D.Float |
getPosition()
|
double |
getRotation()
|
AffineTransform |
getTransform()
|
float |
getWidth()
|
float |
getX()
|
float |
getY()
|
boolean |
isFlipped()
Indicates whether this sprite has been flipped horizontally. |
void |
setAnimation(Animation animation)
Set the displayed animation, replacing the current image or animation. |
void |
setFlipped(boolean flip)
Sets whether this sprite should be flipped horizontally. |
void |
setImage(Image image)
Set the displayed image, replacing the current image or animation. |
void |
setOrigin(float x,
float y)
Set the point on the image which position and rotation operations should treat as the centre. |
void |
setPosition(float x,
float y)
|
void |
setPosition(Point2D p)
|
void |
setReferencePoint(float x,
float y)
Deprecated. |
void |
setRotation(double rotation)
|
void |
setSize(float width,
float height)
|
void |
setX(float x)
|
void |
setY(float y)
|
void |
translate(float dx,
float dy)
|
void |
update(int time)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected float x
protected float y
protected double rotation
| Constructor Detail |
|---|
public Sprite()
public Sprite(float x,
float y)
public Sprite(Image image)
public Sprite(Image image,
float x,
float y)
public Sprite(Animation animation)
public Sprite(Animation animation,
float x,
float y)
| Method Detail |
|---|
public void update(int time)
public Image getImage()
public void setImage(Image image)
public Animation getAnimation()
public void setAnimation(Animation animation)
public float getWidth()
public float getHeight()
public void setSize(float width,
float height)
public void setReferencePoint(float x,
float y)
This defaults to the centre of the image, which is almost always what you want.
x - the x coordinate on the image of the reference pointy - the y coordinate on the image of the reference point
public void setOrigin(float x,
float y)
This defaults to the centre of the image, which is almost always what you want.
x - the x coordinate on the image of the reference pointy - the y coordinate on the image of the reference pointpublic float getX()
public float getY()
public void setX(float x)
public void setY(float y)
public Point2D.Float getPosition()
public void setPosition(float x,
float y)
public void setPosition(Point2D p)
public void translate(float dx,
float dy)
public double getRotation()
public void addRotation(double rotation)
public void setRotation(double rotation)
public boolean isFlipped()
public void setFlipped(boolean flip)
flip - true if this sprite should be flipped horizontally; false otherwisepublic AffineTransform getTransform()
public void draw(Graphics2D g)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||