Package games.stendhal.client.sprite
Interface Sprite
- All Known Implementing Classes:
AnimatedSprite
,CompositeSprite
,EmptySprite
,FlippedSprite
,ImageSprite
,SequenceSprite
,TextSprite
public interface Sprite
A sprite to be displayed on the screen. Note that a sprite contains no state
information, i.e. its just the image and not the location. This allows us to
use a single sprite in lots of different places without having to store
multiple copies of the image.
-
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.int
Get the height of the drawn sprite.Get the sprite reference.int
getWidth()
Get the width of the drawn sprite.default boolean
Check whether the sprite won't change between draws.
-
Method Details
-
createRegion
Create a sub-region of this sprite. NOTE: This does not use caching.- 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
Draw the sprite onto the graphics context provided.- Parameters:
g
- The graphics context on which to draw the spritex
- The x location at which to draw the spritey
- The y location at which to draw the sprite
-
draw
Draws the image.- Parameters:
g
- the graphics context where to draw todestx
- destination xdesty
- destination yx
- the source xy
- the source yw
- the widthh
- the height
-
getHeight
int getHeight()Get the height of the drawn sprite.- Returns:
- The height in pixels of this sprite
-
getReference
Object getReference()Get the sprite reference. This identifier is an externally opaque object that implements equals() and hashCode() to uniquely/repeatably reference a keyed sprite.- Returns:
- The reference identifier, or
null
if not referencable.
-
getWidth
int getWidth()Get the width of the drawn sprite.- Returns:
- The width in pixels of this sprite
-
isConstant
default boolean isConstant()Check whether the sprite won't change between draws.- Returns:
true
if different draws of the sprite always have the same result.
-