Package nl.colorize.multimedialib.stage
Class SpriteAtlas
java.lang.Object
nl.colorize.multimedialib.stage.SpriteAtlas
Packs a number of images into a larger image, with each image existing as
a named region. Using a sprite atlas generally provides better performance
for both loading and rendering images.
Although a sprite atlas is usually expected to consist of one large image, this is not a hard requirement. This class allows the atlas to spread its sub-images across multiple atlases, while still providing central access to all sub-images across all atlas images.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
boolean
Returns the sub-image with the specified name.Returns all sub-images that match the predicate.Returns a list of sub-images that match the requested names.getAll()
Returns all sub-images in this sprite atlas.merge
(SpriteAtlas other) Creates a new sprite atlas that includes all sub-images from both this atlas and the provided other atlas.
-
Constructor Details
-
SpriteAtlas
public SpriteAtlas()
-
-
Method Details
-
add
-
get
Returns the sub-image with the specified name. If the same sub-image is requested multiple times, the image data will be cached and returned on subsequent requests.- Throws:
NoSuchElementException
- if the sprite atlas does not contain a sub-image with that name.
-
get
Returns a list of sub-images that match the requested names. This is a bulk version ofget(String)
. -
get
Returns all sub-images that match the predicate. The sub-images will be returned in alphabetical order based on their name. -
getAll
Returns all sub-images in this sprite atlas. The sub-images will be returned in alphabetical order based on their name. -
contains
-
merge
Creates a new sprite atlas that includes all sub-images from both this atlas and the provided other atlas. Each sprite atlas can span multiple images, as explained in the class documentation, so the combined sprite atlas is transparent to the user.- Throws:
IllegalArgumentException
- If the two atlases do not include sub-images with the same name.
-