public final class Spritesheet extends java.lang.Object implements java.lang.Comparable<Spritesheet>
Constructor and Description |
---|
Spritesheet(java.awt.image.BufferedImage image,
java.lang.String path,
int spriteWidth,
int spriteHeight)
Instantiates a new
Spritesheet instance. |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Spritesheet obj) |
int |
getColumns()
Gets the sprites per row.
|
java.awt.image.BufferedImage |
getImage() |
ImageFormat |
getImageFormat() |
java.lang.String |
getName()
The unique name of this spritesheet.
|
java.awt.image.BufferedImage |
getPreview(int dimension) |
java.awt.image.BufferedImage |
getRandomSprite() |
int |
getRows() |
java.awt.image.BufferedImage |
getSprite(int index) |
java.awt.image.BufferedImage |
getSprite(int index,
int margin,
int spacing) |
int |
getSpriteHeight()
Gets the sprite height.
|
int |
getSpriteWidth()
Gets the sprite width.
|
int |
getTotalNumberOfSprites()
Gets the total sprites.
|
boolean |
isLoaded() |
void |
setSpriteHeight(int spriteHeight) |
void |
setSpriteWidth(int spriteWidth) |
public Spritesheet(java.awt.image.BufferedImage image, java.lang.String path, int spriteWidth, int spriteHeight)
Spritesheet
instance. Depending on the given spriteWidth
and spriteHeight
, the
sub-images will be cropped from the spritesheet image when accessing individual sprites.image
- the spritesheet imagepath
- the path (or name) of the spritesheet imagespriteWidth
- the width in pixels of each sprite in the spritesheet.spriteHeight
- the height in pixels of each sprite in the spritesheet.public int compareTo(Spritesheet obj)
compareTo
in interface java.lang.Comparable<Spritesheet>
public int getColumns()
public java.awt.image.BufferedImage getPreview(int dimension)
public java.awt.image.BufferedImage getImage()
public ImageFormat getImageFormat()
public java.lang.String getName()
public int getRows()
public java.awt.image.BufferedImage getRandomSprite()
public java.awt.image.BufferedImage getSprite(int index)
public java.awt.image.BufferedImage getSprite(int index, int margin, int spacing)
public int getSpriteHeight()
public int getSpriteWidth()
public int getTotalNumberOfSprites()
public boolean isLoaded()
public void setSpriteHeight(int spriteHeight)
public void setSpriteWidth(int spriteWidth)