Class RPGSprite

All Implemented Interfaces:
Graphics, Attachable, Positionable

public class RPGSprite extends Sprite
  • Constructor Details

    • RPGSprite

      public RPGSprite(String name, float width, float height, Positionable parent, RegionOfInterest roi, Vector anchor, float alpha, float depthCorrection)
      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)
      depthCorrection - (float): correction of the deepness defined by the parent position if exists
    • RPGSprite

      public RPGSprite(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
    • RPGSprite

      public RPGSprite(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
    • RPGSprite

      public RPGSprite(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

    • draw

      public void draw(Canvas canvas)
      Description copied from interface: Graphics
      Renders itself on specified canvas.
      Specified by:
      draw in interface Graphics
      Overrides:
      draw in class ImageGraphics
      Parameters:
      canvas - target, not null
    • 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