Package games.stendhal.client.sprite
Class SpriteStore
java.lang.Object
games.stendhal.client.sprite.SpriteStore
A resource manager for sprites in the game. Its often quite important how and
where you get your game resources from. In most cases it makes sense to have
a central resource loader that goes away, gets your resources and caches them
for future use.
[singleton]
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateModifiedRef(String baseRef, Color color, Composite blend)
Get a reference string for a modified sprite.boolean
existsSprite(String ref)
Checks if a file exists.static SpriteStore
get()
Get the single instance of this class.getAnimatedSprite(Sprite sprite, int delay)
Get an animated sprite from a sprite.getAnimatedSprite(Sprite sprite, int width, int delay)
Get an animated sprite from a sprite.getAnimatedSprite(Sprite sprite, int x, int y, int frameCount, int width, int height, int delay)
Create an animated sprite from a tile sprite using pixel units.getColoredSprite(String ref, Color color)
Get a colored version of a sprite.getCombatSprite(String icon)
Retrieve a sprite from the "combat" folderGet an empty sprite with the size of a single tile.getEmptySprite(int width, int height)
Get an empty sprite.Get the failsafe sprite.getModifiedSprite(String baseRef, Color color, Composite blend)
Get a modified version of a sprite.Retrieve a sprite from the store.getStatusSprite(String icon)
Retrieve a sprite from the "status" folderCreate a sprite tile (sub-region).Sprite[]
Get sprite tiles from a sprite using pixel units.modifySprite(Sprite base, Color color, Composite blend, Object ref)
Get a modified variant of a sprite.
-
Constructor Details
-
SpriteStore
protected SpriteStore()
-
-
Method Details
-
get
Get the single instance of this class.- Returns:
- The single instance of this class
-
getAnimatedSprite
public AnimatedSprite getAnimatedSprite(Sprite sprite, int x, int y, int frameCount, int width, int height, int delay)Create an animated sprite from a tile sprite using pixel units.- Parameters:
sprite
- The image which contains the different frames.x
- The base X coordinate (in pixels).y
- The base Y coordinate (in pixels).frameCount
- The number of frames in this animation.width
- The tile width (in pixels).height
- The tile height (in pixels).delay
- The minimum delay between frames.- Returns:
- An animated sprite.
-
getAnimatedSprite
Get an animated sprite from a sprite. The frames are calculated automatically from the dimensions of the origin sprite. The intended frames should be in a row. Each frame will have height of the origin sprite and the specified width. The number of frames will depend on the width of the origin sprite.- Parameters:
sprite
- Origin spritewidth
- frame widthdelay
- delay between the frames- Returns:
- animated sprite
-
getAnimatedSprite
Get an animated sprite from a sprite. The frames are calculated automatically from the dimensions of the origin sprite. The intended frames should be in a row. Each frame will be a square with the height of the origin. The number of frames will depend on the width of the origin sprite.- Parameters:
sprite
- Origin spritedelay
- delay between the frames- Returns:
- animated sprite
-
getTiles
Get sprite tiles from a sprite using pixel units.- Parameters:
sprite
- The base image.x
- The base X coordinate (in pixels).y
- The base Y coordinate (in pixels).count
- The number of tiles.width
- The tile width (in pixels).height
- The tile height (in pixels).- Returns:
- An array of sprites.
-
getFailsafe
Get the failsafe sprite. The failsafe sprite is needed in case there are newer graphic requested in server than in client. It is ok not to return a handmade one. If we cannot reach the failsafe icon, we have bigger problems then just the need to show anything.- Returns:
- The failsafe sprite.
-
getSprite
Retrieve a sprite from the store.- Parameters:
ref
- The reference to the image to use for the sprite- Returns:
- A sprite instance containing an accelerate image of the request reference
-
getCombatSprite
Retrieve a sprite from the "combat" folder- Parameters:
icon
- Name of pixmaps without full path- Returns:
- A sprite instance containing an accelerate image of the request reference
-
getStatusSprite
Retrieve a sprite from the "status" folder- Parameters:
icon
- Name of pixmaps without full path- Returns:
- A sprite instance containing an accelerate image of the request reference
-
getColoredSprite
Get a colored version of a sprite.- Parameters:
ref
- base sprite referencecolor
- painting color- Returns:
- base sprite colored with color
-
getModifiedSprite
Get a modified version of a sprite.- Parameters:
baseRef
- base sprite referencecolor
- modifying colorblend
- composite mode to paint color over the original sprite- Returns:
- base sprite colored with color
-
createModifiedRef
Get a reference string for a modified sprite.- Parameters:
baseRef
- reference for the base spritecolor
-blend
-- Returns:
- reference string
-
modifySprite
Get a modified variant of a sprite. The existence of a previous instance is not checked, so this should not be called unless retrieving an existing modified sprite has failed.- Parameters:
base
- original spritecolor
- adjustment colorblend
- blend mode for applying the adjustment colorref
- reference for the new sprite- Returns:
- modified sprite
-
existsSprite
Checks if a file exists.- Parameters:
ref
- the file name- Returns:
- if sprite exists in store false otherwise
-
getEmptySprite
Get an empty sprite with the size of a single tile.- Returns:
- An empty sprite.
-
getEmptySprite
Get an empty sprite.- Parameters:
width
- The width.height
- The height.- Returns:
- An empty sprite.
-
getTile
Create a sprite tile (sub-region).- Parameters:
sprite
-x
-y
-width
- The width.height
- The height.- Returns:
- tile found in cache or new one created from sprite
-