Class SpriteBasedEntity<T extends SpriteBasedEntity<?>>

All Implemented Interfaces:
Mask
Direct Known Subclasses:
Sprite, TilingSprite

public abstract class SpriteBasedEntity<T extends SpriteBasedEntity<?>> extends TextureBasedEntity<T> implements Mask
A Sprite is a graphical entity which displays an image. That image must be loaded into the viewer's texture cache, which you can configure by adding files to the assets folder of your game's project.
  • Constructor Details

    • SpriteBasedEntity

      public SpriteBasedEntity()
  • Method Details

    • setImage

      public T setImage(String image)
      Sets the image for this Sprite.

      You must either:

      • use the filename of an image relative to the assets folder of the Java project.
      • use the a player's nickname token.
      Parameters:
      image - the name of the image to use for this Sprite.
      Returns:
      this Sprite.
    • setBaseWidth

      public T setBaseWidth(int baseWidth)
      Sets the image base width for this Sprite. If not set, the image base width is the real image width.
      Parameters:
      baseWidth - image width
      Returns:
      this Sprite.
    • setBaseHeight

      public T setBaseHeight(int baseHeight)
      Sets the image base height for this Sprite. If not set, the image base height is the real image height.
      Parameters:
      baseHeight - image height
      Returns:
      this Sprite.
    • getImage

      public String getImage()
      Returns the name of the image used for this Sprite.

      Can be a player's nickname token.

      Returns:
      the name of the image used for this Sprite
    • getBaseWidth

      public Integer getBaseWidth()
      Returns the image base width for this Sprite. If not set, the image base width is the real image width, but this will return null.
      Returns:
      the image base width for this Sprite.
    • getBaseHeight

      public Integer getBaseHeight()
      Returns the image base height for this Sprite. If not set, the image base height is the real image height, but this will return null.
      Returns:
      the image base height for this Sprite.
    • setScaleMode

      public T setScaleMode(ScaleMode scaleMode)
      Sets the scale mode of this TextureBasedEntity.

      Default is LINEAR.

      Parameters:
      scaleMode - the scale mode of this TextureBasedEntity.
      Returns:
      this TextureBasedEntity.
    • getScaleMode

      public ScaleMode getScaleMode()
      Returns the scale mode of this TextureBasedEntity.

      Default is LINEAR.

      Returns:
      the scale mode of this TextureBasedEntity.