Package games.stendhal.client.gui.j2d
Class RemovableSprite
java.lang.Object
games.stendhal.client.gui.j2d.RemovableSprite
- All Implemented Interfaces:
Comparable<RemovableSprite>
Container sprite for texboxes etc. Keeps track of the time when the sprite
should be removed. Also implements Comparable in a way that more important
sprites can be placed above less important ones.
Note: this class has a natural ordering that is inconsistent with equals.
Note: this class has a natural ordering that is inconsistent with equals.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRemovableSprite(Sprite sprite, int x, int y, long persistTime)
Create a new text object. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo(RemovableSprite other)
void
Draw the contained sprite.getArea()
Get the area the sprite covers.int
getX()
Get the position of the left side of the sprite.int
getY()
Get the position of the top of the sprite.void
setPriority(int priority)
Set the priority of the message.boolean
Check if theText
is old enough to be removed.
-
Field Details
-
STANDARD_PERSISTENCE_TIME
public static final long STANDARD_PERSISTENCE_TIME- See Also:
- Constant Field Values
-
-
Constructor Details
-
RemovableSprite
Create a new text object.- Parameters:
sprite
-x
- x coordinate relative to the game screeny
- y coordinate relative to the game screenpersistTime
- life time of the text object in milliseconds, or 0 forSTANDARD_PERSISTENCE_TIME
-
-
Method Details
-
draw
Draw the contained sprite.- Parameters:
g
- graphics
-
getArea
Get the area the sprite covers.- Returns:
- sprite area
-
getX
public int getX()Get the position of the left side of the sprite.- Returns:
- x coordinate
-
getY
public int getY()Get the position of the top of the sprite.- Returns:
- y coordinate
-
setPriority
public void setPriority(int priority)Set the priority of the message. Higher priority messages are kept above others; sprites of the same priority are ordered newest on top.- Parameters:
priority
-
-
shouldBeRemoved
public boolean shouldBeRemoved()Check if theText
is old enough to be removed.- Returns:
true
if the text should be removed
-
compareTo
- Specified by:
compareTo
in interfaceComparable<RemovableSprite>
-