public class SpriteImpl extends java.lang.Object implements Sprite
Modifier and Type | Field and Description |
---|---|
protected int |
height |
protected int |
heightOriginal |
protected java.awt.image.BufferedImage |
surface |
protected int |
width |
protected int |
widthOriginal |
Constructor and Description |
---|
SpriteImpl(java.awt.image.BufferedImage surface) |
SpriteImpl(java.lang.String filename)
Create a new sprite.
|
Modifier and Type | Method and Description |
---|---|
Sprite |
clone()
Get cloned version of current sprite.
|
void |
filter(Filter filter)
Apply a filter to the sprite.
|
void |
flipHorizontal()
Flip the sprite horizontaly.
|
void |
flipVertical()
Flip the sprite verticaly.
|
int |
getHeight()
Get the image height size.
|
int |
getHeightOriginal()
Get the current sprite height (its current size, after scaling operation).
|
java.awt.image.BufferedImage |
getSurface()
Get the sprite surface, represented by a BufferedImage, java type.
|
int |
getWidth()
Get the image width size.
|
int |
getWidthOriginal()
Get the current sprite width (its current size, after scaling operation).
|
void |
render(java.awt.Graphics2D g,
int x,
int y)
Render image on current graphic output, at specified coordinates.
|
void |
rotate(int angle)
Rotate the sprite with the specified angle.
|
void |
scale(int percent)
Method used for sprite scaling, in order to modify its size.
|
void |
stretch(int widthPercent,
int heightPercent)
Works as scale, but using differents width and height factor.
|
java.lang.String |
toString() |
protected java.awt.image.BufferedImage surface
protected int width
protected int height
protected int widthOriginal
protected int heightOriginal
public SpriteImpl(java.lang.String filename)
filename
- image path.public SpriteImpl(java.awt.image.BufferedImage surface)
public void scale(int percent)
Sprite
public void stretch(int widthPercent, int heightPercent)
Sprite
public void rotate(int angle)
Sprite
public void flipHorizontal()
Sprite
flipHorizontal
in interface Sprite
public void flipVertical()
Sprite
flipVertical
in interface Sprite
public void filter(Filter filter)
Sprite
public void render(java.awt.Graphics2D g, int x, int y)
Renderable
render
in interface Renderable
g
- graphic output.x
- abscissa.y
- ordinate.public int getWidth()
Renderable
getWidth
in interface Renderable
public int getHeight()
Renderable
getHeight
in interface Renderable
public int getWidthOriginal()
Sprite
getWidthOriginal
in interface Sprite
public int getHeightOriginal()
Sprite
getHeightOriginal
in interface Sprite
public java.awt.image.BufferedImage getSurface()
Sprite
getSurface
in interface Image
getSurface
in interface Sprite
public java.lang.String toString()
toString
in class java.lang.Object