Class SimpleFrames

java.lang.Object
tripleplay.util.SimpleFrames
All Implemented Interfaces:
Frames

public class SimpleFrames extends Object implements Frames
A simple implementation of Frames that uses an untrimmed horizontal strip image.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SimpleFrames(Tile source, float width)
    Creates an instance with the supplied source texture.
    SimpleFrames(Tile source, float width, float height)
    Creates an instance with the supplied source texture.
    SimpleFrames(TileSource source, float width, float height, int count)
    Creates an instance with the supplied tile source.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    apply(int index, ImageLayer layer)
    Configures the supplied image layer with the specified frame.
    pythagoras.f.IRectangle
    bounds(int index)
    Returns the bounds for the specified frame.
    int
    Returns the number of frames available.
    float
    Returns the height of a logical frame.
    pythagoras.f.IPoint
    offset(int index)
    Returns the offset (into the logical bounds) of the specified frame.
    float
    Returns the width of a logical frame.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SimpleFrames

      public SimpleFrames(Tile source, float width)
      Creates an instance with the supplied source texture. The frames are assumed to be all in a single row, thus the height of the image defines the height of the frame.
      Parameters:
      width - the width of each frame.
    • SimpleFrames

      public SimpleFrames(Tile source, float width, float height)
      Creates an instance with the supplied source texture. The image is assumed to contain a complete sheet of frames, each width x height in size.
      Parameters:
      width - the width of each frame.
      height - the width of each frame.
    • SimpleFrames

      public SimpleFrames(TileSource source, float width, float height, int count)
      Creates an instance with the supplied tile source. The tile is assumed to contain count frames, each width x height in size, in row major order (any missing frames are on the right side of the bottom row).
      Parameters:
      width - the width of each frame.
      height - the width of each frame.
  • Method Details

    • width

      public float width()
      Description copied from interface: Frames
      Returns the width of a logical frame.
      Specified by:
      width in interface Frames
    • height

      public float height()
      Description copied from interface: Frames
      Returns the height of a logical frame.
      Specified by:
      height in interface Frames
    • count

      public int count()
      Description copied from interface: Frames
      Returns the number of frames available.
      Specified by:
      count in interface Frames
    • bounds

      public pythagoras.f.IRectangle bounds(int index)
      Description copied from interface: Frames
      Returns the bounds for the specified frame.
      Specified by:
      bounds in interface Frames
    • offset

      public pythagoras.f.IPoint offset(int index)
      Description copied from interface: Frames
      Returns the offset (into the logical bounds) of the specified frame.
      Specified by:
      offset in interface Frames
    • apply

      public void apply(int index, ImageLayer layer)
      Description copied from interface: Frames
      Configures the supplied image layer with the specified frame. The layer's image will be updated and the layer's translation will be adjusted to the requested frame's offset
      Specified by:
      apply in interface Frames