Class Spritesheet

All Implemented Interfaces:

public final class Spritesheet
extends java.lang.Object
implements java.lang.Comparable<Spritesheet>
  • Constructor Details

    • Spritesheet

      public Spritesheet​(java.awt.image.BufferedImage image, java.lang.String path, int spriteWidth, int spriteHeight)
      Instantiates a new Spritesheet instance. Depending on the given spriteWidth and spriteHeight, the sub-images will be cropped from the spritesheet image when accessing individual sprites.
      image - the spritesheet image
      path - the path (or name) of the spritesheet image
      spriteWidth - the width in pixels of each sprite in the spritesheet.
      spriteHeight - the height in pixels of each sprite in the spritesheet.
  • Method Details

    • compareTo

      public int compareTo​(Spritesheet obj)
      Specified by:
      compareTo in interface java.lang.Comparable<Spritesheet>
    • getColumns

      public int getColumns()
      Gets the sprites per row.
      the sprites per row
    • getPreview

      public java.awt.image.BufferedImage getPreview​(int dimension)
    • getImage

      public java.awt.image.BufferedImage getImage()
    • getImageFormat

      public ImageFormat getImageFormat()
    • getName

      public java.lang.String getName()
      The unique name of this spritesheet. A spritesheet can always be identified by this name within a game project.
      The name of the spritesheet.
    • getRows

      public int getRows()
    • getRandomSprite

      public java.awt.image.BufferedImage getRandomSprite()
    • getSprite

      public java.awt.image.BufferedImage getSprite​(int index)
    • getSprite

      public java.awt.image.BufferedImage getSprite​(int index, int margin, int spacing)
    • getSpriteHeight

      public int getSpriteHeight()
      Gets the sprite height.
      the sprite height
    • getSpriteWidth

      public int getSpriteWidth()
      Gets the sprite width.
      the sprite width
    • getTotalNumberOfSprites

      public int getTotalNumberOfSprites()
      Gets the total sprites.
      the total sprites
    • isLoaded

      public boolean isLoaded()
    • setSpriteHeight

      public void setSpriteHeight​(int spriteHeight)
    • setSpriteWidth

      public void setSpriteWidth​(int spriteWidth)