Class Sprite

All Implemented Interfaces:
Graphics, Attachable, Positionable
Direct Known Subclasses:
RPGSprite

public class Sprite extends ImageGraphics
  • Constructor Details

    • Sprite

      public Sprite(String name, float width, float height, Positionable parent, RegionOfInterest roi, Vector anchor, float alpha, float depth)
      Creates a new Sprite.
      Parameters:
      name - (String): image name, may be null
      width - (int): actual image width, before transformation
      height - (int): actual image height, before transformation
      parent - (Positionable): parent of this, not null
      roi - (RegionOfInterest): region of interest into the image as a rectangle in the image. May be null
      anchor - (Vector): image anchor, not null
      alpha - (float): transparency, between 0 (invisible) and 1 (opaque)
      depth - (float): render priority, lower-values drawn first
    • Sprite

      public Sprite(String name, float width, float height, Positionable parent, RegionOfInterest roi, Vector anchor)
      Creates a new image graphics.
      Parameters:
      name - (String): image name, not null
      width - (int): actual image width, before transformation
      height - (int): actual image height, before transformation
      parent - (Positionable): parent of this, not null
      roi - (RegionOfInterest): region of interest into the image as a rectangle in the image. May be null
      anchor - (Vector): image anchor, not null
    • Sprite

      public Sprite(String name, float width, float height, Positionable parent, RegionOfInterest roi)
      Creates a new image graphics.
      Parameters:
      name - (String): image name, not null
      width - (int): actual image width, before transformation
      height - (int): actual image height, before transformation
      parent - (Positionable): parent of this, not null
      roi - (RegionOfInterest): region of interest into the image as a rectangle in the image. May be null
    • Sprite

      public Sprite(String name, float width, float height, Positionable parent)
      Creates a new image graphics.
      Parameters:
      name - (String): image name, not null
      width - (int): actual image width, before transformation
      height - (int): actual image height, before transformation
      parent - (Positionable): parent of this, not null
  • Method Details

    • extractSprites

      public static Sprite[][] extractSprites(String name, int nbFrames, float width, float height, Positionable parent, int regionWidth, int regionHeight, Vector anchor, Orientation[] order)
      Extracts from an image the sprites corresponding to a given orientation the returned array has 4 entry (one per orientation) the content of each entry is an array of sprites corresponding to the given orientation (the entry indexed by Orientation.dir.ordinal() is the array of sprites corresponding to the orientation Orientation.dir).
      Parameters:
      name - (String): the name of the image
      nbFrames - (int): number of frames in each row
      width - (int): actual image width, before transformation
      height - (int): actual image height, before transformation
      parent - (Positionable): parent of this, not null
      regionWidth - (int): width of frame (number of pixels in the image)
      regionHeight - (int): height of frame (number of pixels in the image)
      anchor - (Vector) : image anchor, not null
      order - (Orientation[]): order of the frames in the image
      Returns:
      an array of 4 Sprite[] (one Sprite[] per orientation)
    • extractSprites

      public static Sprite[][] extractSprites(String name, int nbFrames, float width, float height, Positionable parent, int regionWidth, int regionHeight, Orientation[] order)
      Extracts from an image the sprites corresponding to a given orientation the returned array has 4 entry (one per orientation) the content of each entry is an array of sprites corresponding to the given orientation (the entry indexed by Orientation.dir.ordinal() is the array of sprites corresponding to the orientation Orientation.dir).
      Parameters:
      name - (String): the name of the image
      nbFrames - (int): number of frames in each row
      width - (int): actual image width, before transformation
      height - (int): actual image height, before transformation
      parent - (Positionable): parent of this, not null
      regionWidth - (int): width of frame (number of pixels in the image)
      regionHeight - (int): height of frame (number of pixels in the image)
      order - (Orientation[]): order of the frames in the image
      Returns:
      an array of 4 Sprite[] (one Sprite[] per orientation)
    • extractSprites

      public static Sprite[] extractSprites(String name, int nbFrames, float width, float height, Positionable parent, Vector anchor, int regionWidth, int regionHeight)
      Extracts from an image the sprites
      Parameters:
      name - (String): the name of the image
      nbFrames - (int): number of frames in each row
      width - (int): actual image width, before transformation
      height - (int): actual image height, before transformation
      parent - (Positionable): parent of this, not null
      anchor - (Vector) : image anchor, not null
      regionWidth - (int): width of frame (number of pixels in the image)
      regionHeight - (int): height of frame (number of pixels in the image)
      Returns:
      an array of Sprite
    • extractSprites

      public static Sprite[] extractSprites(String name, int nbFrames, float width, float height, Positionable parent, int regionWidth, int regionHeight)
      Extracts from an image the sprites
      Parameters:
      name - (String): the name of the image
      nbFrames - (int): number of frames in each row
      width - (int): actual image width, before transformation
      height - (int): actual image height, before transformation
      parent - (Positionable): parent of this, not null
      regionWidth - (int): width of frame (number of pixels in the image)
      regionHeight - (int): height of frame (number of pixels in the image)
      Returns:
      an array of Sprite