Class SpriteSheetSplitter
java.lang.Object
com.codingame.gameengine.module.entities.SpriteSheetSplitter
Utility to load an image containing several subimages displayed in sequential rectangles.
Will extract each separate image and return generated names that can be used to create a Sprite
or SpriteAnimation
-
Constructor Summary
ConstructorDescriptionSpriteSheetSplitter
(GraphicEntityModule graphicEntityModule) The constructor expected to be called by Guice. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the height of subimagesint
Returns number of subimages to extractint
Returns number of subimages to extract per row.getName()
Returns the prefix of all subimage namesint
Returns from which column of subimages to start extracting subimagesint
Returns from which row of subimages to start extracting subimagesReturns the image from which subimages will be extractedint
getWidth()
Returns the width of subimagessetHeight
(int height) Sets the height of the subimages to extract Defaults to full height of spritesheet if not setsetImageCount
(int imageCount) Sets the number of subimages to be extractedsetImagesPerRow
(int imagesPerRow) Sets the number of subimages to extract per row before advancing to theorigCol
th column of the next row.Sets the prefix of all subimage names.setOrigCol
(int origCol) Sets the column of subimages from which subimages start being extractingsetOrigRow
(int origRow) Sets the row of subimages from which subimages start being extractingsetSourceImage
(String sourceImage) Sets the image from which to extract subimagessetWidth
(int width) Sets the width of the subimages to extract Defaults to full width of spritesheet if not setString[]
split()
Splits up a spritesheet (all fields are required except imagesPerRow).
-
Constructor Details
-
SpriteSheetSplitter
The constructor expected to be called by Guice. UseGraphicEntityModule.createSpriteSheetSplitter()
to instantiate- Parameters:
graphicEntityModule
- the singleton to be injected
-
-
Method Details
-
getName
Returns the prefix of all subimage names- Returns:
- the prefix of all subimage names
-
getSourceImage
Returns the image from which subimages will be extracted- Returns:
- the image from which subimages will be extracted
-
getWidth
public int getWidth()Returns the width of subimages- Returns:
- the width of subimages
-
getHeight
public int getHeight()Returns the height of subimages- Returns:
- the height of subimages
-
getOrigRow
public int getOrigRow()Returns from which row of subimages to start extracting subimages- Returns:
- from which row of subimages to start extracting subimages
-
getOrigCol
public int getOrigCol()Returns from which column of subimages to start extracting subimages- Returns:
- from which column of subimages to start extracting subimages
-
getImageCount
public int getImageCount()Returns number of subimages to extract- Returns:
- number of subimages to extract
-
getImagesPerRow
public int getImagesPerRow()Returns number of subimages to extract per row. Extraction will continue atorigCol
on the next row.- Returns:
- number of subimages to extract per row. Extraction will continue at
origCol
on the next row.
-
setName
Sets the prefix of all subimage names.- Parameters:
name
- the prefix of all subimages- Returns:
- this
SpriteSheetSplitter
-
setSourceImage
Sets the image from which to extract subimages- Parameters:
sourceImage
- the image from which to extract subimages- Returns:
- this
SpriteSheetSplitter
-
setWidth
Sets the width of the subimages to extract Defaults to full width of spritesheet if not set- Parameters:
width
- the width of the subimages- Returns:
- this
SpriteSheetSplitter
-
setHeight
Sets the height of the subimages to extract Defaults to full height of spritesheet if not set- Parameters:
height
- the height of the subimages- Returns:
- this
SpriteSheetSplitter
-
setOrigRow
Sets the row of subimages from which subimages start being extracting- Parameters:
origRow
- the row of subimages from which subimages start being extracting- Returns:
- this
SpriteSheetSplitter
-
setOrigCol
Sets the column of subimages from which subimages start being extracting- Parameters:
origCol
- the column of subimages from which subimages start being extracting- Returns:
- this
SpriteSheetSplitter
-
setImageCount
Sets the number of subimages to be extracted- Parameters:
imageCount
- the number of subimages to be extracted- Returns:
- this
SpriteSheetSplitter
-
setImagesPerRow
Sets the number of subimages to extract per row before advancing to theorigCol
th column of the next row.- Parameters:
imagesPerRow
- the number of subimages to extract per row before advancing to theorigCol
th column of the next row.- Returns:
- this
SpriteSheetSplitter
-
split
Splits up a spritesheet (all fields are required except imagesPerRow). Returns an array of image names that can be used in Sprite or SpriteAnimation.- Returns:
- an array of image names.
-