Package games.stendhal.client.sprite
Class CompositeSprite
java.lang.Object
games.stendhal.client.sprite.CompositeSprite
- All Implemented Interfaces:
Sprite
A sprite that merges several
Sprite
objects to one, and pre-renders
those it can so that they do not need to be composited every time the sprite
is drawn.-
Method Summary
Modifier and TypeMethodDescriptioncreateRegion(int x, int y, int width, int height, Object ref)
Create a sub-region of this sprite.void
Draw the sprite onto the graphics context provided.void
Draws the image.static Sprite
getComposite(SpriteCache cache, List<Sprite> slaves, Composite blend, Sprite adj)
Get a composite of at least oneSprite
.int
Get the height of the drawn sprite.Get the sprite reference.int
getWidth()
Get the width of the drawn sprite.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface games.stendhal.client.sprite.Sprite
isConstant
-
Method Details
-
getComposite
public static Sprite getComposite(SpriteCache cache, List<Sprite> slaves, Composite blend, Sprite adj)Get a composite of at least oneSprite
. Note that the result is not necessarily a CompositeSprite, but can well be one of the slave sprites if the said sprite is enough to represent the entire composite. The composite can have also one sprite, which is composited above the others using a special blend mode.- Parameters:
cache
- Cache to look up a previously stored, and storing newly created compositesslaves
- Sprites making up the composite. The list should be non-null and not empty. Also the sprites themselves should be non-null.blend
- Blend mode for the special adjustment sprite, ornull
, if no adjustments are wantedadj
- adjustment sprite, ornull
- Returns:
- A Sprite representing a composite of the slave Sprites
-
createRegion
Description copied from interface:Sprite
Create a sub-region of this sprite. NOTE: This does not use caching.- Specified by:
createRegion
in interfaceSprite
- Parameters:
x
- The starting X coordinate.y
- The starting Y coordinate.width
- The region width.height
- The region height.ref
- The sprite reference.- Returns:
- A new sprite.
-
draw
Description copied from interface:Sprite
Draw the sprite onto the graphics context provided. -
draw
Description copied from interface:Sprite
Draws the image. -
getHeight
public int getHeight()Description copied from interface:Sprite
Get the height of the drawn sprite. -
getReference
Description copied from interface:Sprite
Get the sprite reference. This identifier is an externally opaque object that implements equals() and hashCode() to uniquely/repeatably reference a keyed sprite.- Specified by:
getReference
in interfaceSprite
- Returns:
- The reference identifier, or
null
if not referencable.
-
getWidth
public int getWidth()Description copied from interface:Sprite
Get the width of the drawn sprite.
-