| Modifier | Constructor and Description |
|---|---|
protected |
DefaultSprite()
When using this constructor you'll have to override all methods.
|
|
DefaultSprite(BufferedImage image,
int width,
int height)
Create a new sprite.
|
| Modifier and Type | Method and Description |
|---|---|
void |
draw(Graphics2D g,
int width,
int height)
Draws the image on a given
Graphics2D object |
void |
drawTile(Graphics2D g,
int x,
int y,
int width,
int height)
Draws a tile of this sprite.
|
int |
getColumns()
Get the number of columns.
|
int |
getRows()
Get the number of rows.
|
Size |
getSize()
Get the original size of the image
|
Sprite |
getSubSprite(int x,
int y,
int width,
int height)
Get sub-sprite with given dimension.
|
BufferedImage |
getTile(int x,
int y)
Get a tile of this sprite.
|
int |
getTileCount()
Get the number of tiles in this sprite.
|
int |
getTileHeight()
Get the height of one tile
|
int |
getTileWidth()
Get the width of one tile
|
public DefaultSprite(BufferedImage image, int width, int height)
BufferedImage will be used as is. So consider passing
a copy of your original image.image - The image that contains the sub-imageswidth - Width of one sub-imageheight - Height of one sub-imageprotected DefaultSprite()
public void drawTile(Graphics2D g, int x, int y, int width, int height)
SpriteBounds(0, 0,
width, height). Consider creating a clipped Graphics2D object.drawTile in interface Spriteg - Graphics2D object to draw onx - X-Coordinate of the tiley - Y-Coordinate of the tilewidth - The width of the Graphics object to draw onheight - The height of the Graphics object to draw onpublic void draw(Graphics2D g, int width, int height)
ImageGraphics2D objectpublic BufferedImage getTile(int x, int y)
SpriteSprite.drawTile(Graphics2D, int, int, int, int) for faster action and less memory
usage.getTile in interface Spritex - X-Coordinate of the tiley - Y-Coordinate of the tileBufferedImage containing the tilepublic Size getSize()
Imagepublic int getTileCount()
SpritegetTileCount in interface Spritepublic int getRows()
Spritepublic int getColumns()
SpritegetColumns in interface Spritepublic int getTileWidth()
SpritegetTileWidth in interface Spritepublic int getTileHeight()
SpritegetTileHeight in interface Spritepublic Sprite getSubSprite(int x, int y, int width, int height)
SpriteDerivedSprite is linked with this
sprite.getSubSprite in interface Spritex - X-Coordinate of first tiley - Y-Coordinate of first tilewidth - Width of the sub-spriteheight - Height of the sub-spriteDerivedSpriteCopyright © 2017. All rights reserved.