public class WeakSprite extends DefaultSprite
Sprite caches tiles with WeakReference in order to find a
balance between time and memory| Constructor and Description |
|---|
WeakSprite(BufferedImage image,
int width,
int height)
Create a new sprite.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
draw, drawTile, getColumns, getRows, getSize, getTileCount, getTileHeight, getTileWidthpublic WeakSprite(BufferedImage image, int width, int height)
BufferedImage will be used as is. So consider passing
a copy of your original image. Calls to getTile(int, int) will be buffered. So
changes maybe ignored or delayed. Calls to DefaultSprite.drawTile(Graphics2D, int, int, int, int)
won't be buffered.image - The image that contains the sub-imageswidth - Width of one sub-imageheight - Height of one sub-imagepublic BufferedImage getTile(int x, int y)
SpriteSprite.drawTile(Graphics2D, int, int, int, int) for faster action and less memory
usage.getTile in interface SpritegetTile in class DefaultSpritex - X-Coordinate of the tiley - Y-Coordinate of the tileBufferedImage containing the tilepublic Sprite getSubSprite(int x, int y, int width, int height)
SpriteDerivedSprite is linked with this
sprite.getSubSprite in interface SpritegetSubSprite in class DefaultSpritex - X-Coordinate of first tiley - Y-Coordinate of first tilewidth - Width of the sub-spriteheight - Height of the sub-spriteDerivedSpriteCopyright © 2017. All rights reserved.