public class SpriteSheet
extends java.lang.Object
A SpriteSheet is a rectangular grid of Sprites. Each Sprite has an x-coordinate in the grid that starts at 0 for the leftmost column and increases to the right, as well as a y-coordinate that starts at 0 for the topmost row and increases below. Like Sprites, Sounds, and Music tracks, SpriteSheets can be manually loaded and unloaded into and out of memory. Loading may take a moment, but a SpriteSheet's Sprites cannot be loaded and drawn if the SpriteSheet itself is not loaded. Thus, loading a Sprite that is part of a SpriteSheet will also load its SpriteSheet.
Constructor and Description |
---|
SpriteSheet(SpriteSheet spriteSheet,
Filter filter,
boolean load)
Creates a new SpriteSheet from an existing SpriteSheet with a Filter
applied to it.
|
SpriteSheet(java.lang.String path,
int width,
int height,
int spriteWidth,
int spriteHeight,
int spriteSpacing,
int originX,
int originY,
org.newdawn.slick.Color transColor,
java.util.Set<Filter> filters,
boolean load)
Creates a new SpriteSheet from an image file.
|
SpriteSheet(java.lang.String path,
int width,
int height,
int spriteWidth,
int spriteHeight,
int spriteSpacing,
int originX,
int originY,
int transR,
int transG,
int transB,
java.util.Set<Filter> filters,
boolean load)
Creates a new SpriteSheet from an image file.
|
SpriteSheet(java.lang.String path,
int width,
int height,
int spriteWidth,
int spriteHeight,
int spriteSpacing,
int originX,
int originY,
java.util.Set<Filter> filters,
boolean load)
Creates a new SpriteSheet from an image file.
|
Modifier and Type | Method and Description |
---|---|
java.util.Set<Filter> |
getFilters()
Returns the Set of Filters that will have an effect on this SpriteSheet's
Sprites when applied to them with draw().
|
int |
getHeight()
Returns the height in Sprites of this SpriteSheet.
|
int |
getOriginX()
Returns the x-coordinate in pixels on each of this SpriteSheet's Sprites
of its origin.
|
int |
getOriginY()
Returns the y-coordinate in pixels on each of this SpriteSheet's Sprites
of its origin.
|
Sprite |
getSprite(int x,
int y)
Returns the Sprite at the specified coordinates.
|
int |
getWidth()
Returns the width in Sprites of this SpriteSheet.
|
boolean |
isLoaded()
Returns whether this SpriteSheet is loaded.
|
boolean |
load()
Loads this SpriteSheet, along with all of its Sprites, if it is not
already loaded.
|
boolean |
unload()
Unloads this SpriteSheet, along with all of its Sprites, if it is
currently loaded.
|
public SpriteSheet(java.lang.String path, int width, int height, int spriteWidth, int spriteHeight, int spriteSpacing, int originX, int originY, java.util.Set<Filter> filters, boolean load) throws org.newdawn.slick.SlickException
path
- The relative path to the image filewidth
- The width in Sprites of this SpriteSheetheight
- The height in Sprites of this SpriteSheetspriteWidth
- The width in pixels of each SpritespriteHeight
- The height in pixels of each SpritespriteSpacing
- The horizontal and vertical spacing in pixels
between SpritesoriginX
- The x-coordinate in pixels on each Sprite of its originoriginY
- The y-coordinate in pixels on each Sprite of its originfilters
- The Set of Filters that will have an effect on this
SpriteSheet's Sprites when applied to them with draw()load
- Whether this SpriteSheet should load upon creationorg.newdawn.slick.SlickException
- If the SpriteSheet could not be properly loaded
from the specified pathpublic SpriteSheet(java.lang.String path, int width, int height, int spriteWidth, int spriteHeight, int spriteSpacing, int originX, int originY, org.newdawn.slick.Color transColor, java.util.Set<Filter> filters, boolean load) throws org.newdawn.slick.SlickException
path
- The relative path to the image filewidth
- The width in Sprites of this SpriteSheetheight
- The height in Sprites of this SpriteSheetspriteWidth
- The width in pixels of each SpritespriteHeight
- The height in pixels of each SpritespriteSpacing
- The horizontal and vertical spacing in pixels
between SpritesoriginX
- The x-coordinate in pixels on each Sprite of its originoriginY
- The y-coordinate in pixels on each Sprite of its origintransColor
- The transparent color of this SpriteSheet's Sprites, or
null if there should be nonefilters
- The Set of Filters that will have an effect on this
SpriteSheet's Sprites when applied to them with draw()load
- Whether this SpriteSheet should load upon creationorg.newdawn.slick.SlickException
- If the SpriteSheet could not be properly loaded
from the specified pathpublic SpriteSheet(java.lang.String path, int width, int height, int spriteWidth, int spriteHeight, int spriteSpacing, int originX, int originY, int transR, int transG, int transB, java.util.Set<Filter> filters, boolean load) throws org.newdawn.slick.SlickException
path
- The relative path to the image filewidth
- The width in Sprites of this SpriteSheetheight
- The height in Sprites of this SpriteSheetspriteWidth
- The width in pixels of each SpritespriteHeight
- The height in pixels of each SpritespriteSpacing
- The horizontal and vertical spacing in pixels
between SpritesoriginX
- The x-coordinate in pixels on each Sprite of its originoriginY
- The y-coordinate in pixels on each Sprite of its origintransR
- The R value (0-255) of this SpriteSheet's Sprites'
transparent colortransG
- The G value (0-255) of this SpriteSheet's Sprites'
transparent colortransB
- The B value (0-255) of this SpriteSheet's Sprites'
transparent colorfilters
- The Set of Filters that will have an effect on this
SpriteSheet's Sprites when applied to them with draw()load
- Whether this SpriteSheet should load upon creationorg.newdawn.slick.SlickException
- If the SpriteSheet could not be properly loaded
from the specified pathpublic SpriteSheet(SpriteSheet spriteSheet, Filter filter, boolean load) throws org.newdawn.slick.SlickException
spriteSheet
- The SpriteSheet to create this SpriteSheet fromfilter
- The Filter to apply to the existing SpriteSheetload
- Whether this SpriteSheet should load upon creationorg.newdawn.slick.SlickException
- If the SpriteSheet could not be properly loadedpublic final boolean isLoaded()
public final boolean load() throws org.newdawn.slick.SlickException
org.newdawn.slick.SlickException
- If the SpriteSheet could not be properly loadedpublic final boolean unload()
public final java.util.Set<Filter> getFilters()
public final int getWidth()
public final int getHeight()
public final int getOriginX()
public final int getOriginY()
public Sprite getSprite(int x, int y)
x
- The x-coordinate in Sprites of the Spritey
- The y-coordinate in Sprites of the Sprite