Class RemovableSprite

java.lang.Object
games.stendhal.client.gui.j2d.RemovableSprite
All Implemented Interfaces:
Comparable<RemovableSprite>

public class RemovableSprite extends Object implements 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.
  • Field Details

    • STANDARD_PERSISTENCE_TIME

      public static final long STANDARD_PERSISTENCE_TIME
      See Also:
      Constant Field Values
  • Constructor Details

    • RemovableSprite

      public RemovableSprite(Sprite sprite, int x, int y, long persistTime)
      Create a new text object.
      Parameters:
      sprite -
      x - x coordinate relative to the game screen
      y - y coordinate relative to the game screen
      persistTime - life time of the text object in milliseconds, or 0 for STANDARD_PERSISTENCE_TIME
  • Method Details

    • draw

      public void draw(Graphics g)
      Draw the contained sprite.
      Parameters:
      g - graphics
    • getArea

      public Rectangle 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 the Text is old enough to be removed.
      Returns:
      true if the text should be removed
    • compareTo

      public int compareTo(RemovableSprite other)
      Specified by:
      compareTo in interface Comparable<RemovableSprite>