public class BufferedSprite extends Object implements Sprite
Sprite
that initially divides the provided image into sub-images. First creation is
slower and consumes more memory than the unbuffered Sprite, but calls to get/drawTile are much
faster.Constructor and Description |
---|
BufferedSprite(BufferedImage image,
int width,
int height)
Creates a new
BufferedSprite . |
Modifier and Type | Method and Description |
---|---|
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.
|
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 BufferedSprite(BufferedImage image, int width, int height)
BufferedSprite
. The given BufferedImage
is copied.public void drawTile(Graphics2D g, int x, int y, int width, int height)
Bounds(0, 0,
width, height)
.public BufferedImage getTile(int x, int y)
drawTile(Graphics2D, int, int, int, int)
for faster
action.getTile
in interface Sprite
x
- X-Coordinate of the tiley
- Y-Coordinate of the tileBufferedImage
containing the tilepublic int getTileCount()
Sprite
getTileCount
in interface Sprite
public int getRows()
Sprite
public int getColumns()
Sprite
getColumns
in interface Sprite
public int getTileWidth()
Sprite
getTileWidth
in interface Sprite
public int getTileHeight()
Sprite
getTileHeight
in interface Sprite
public Sprite getSubSprite(int x, int y, int width, int height)
Sprite
DerivedSprite
is linked with this
sprite.getSubSprite
in interface Sprite
x
- X-Coordinate of first tiley
- Y-Coordinate of first tilewidth
- Width of the sub-spriteheight
- Height of the sub-spriteDerivedSprite
Copyright © 2017. All rights reserved.