Package gui

Class Sprite

java.lang.Object
gui.Sprite

public class Sprite extends Object
An instance maintains information about a sprite for the GUI. A sprite is defined by a spritesheet, the information to interpret it (size of each image, etc.), and information necessary to animate the sprite.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Sprite(String imageLoc, int width, int height, int cycleSize)
    Constructor: an instance with image at imageLoc, of size (width, height), and number of frames in the animation cycleSize.
  • Method Summary

    Modifier and Type
    Method
    Description
    getSprite(int dRow, int dCol)
    Return offset (dRow, dCol) into the spritesheet.
    void
    Update the spritesheet's animation by a single frame.

    Methods inherited from class java.lang.Object

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

    • Sprite

      public Sprite(String imageLoc, int width, int height, int cycleSize)
      Constructor: an instance with image at imageLoc, of size (width, height), and number of frames in the animation cycleSize.
  • Method Details

    • tick

      public void tick()
      Update the spritesheet's animation by a single frame.
    • getSprite

      public BufferedImage getSprite(int dRow, int dCol)
      Return offset (dRow, dCol) into the spritesheet. Assume that (dRow, dCol) is the base offset, and subsequent animations are at (dRow, dCol + 1), (dRow, dCol + 2) ... (dRow, dCol + cycleSize - 1)
      Parameters:
      dRow - the number of rows to offset into the spritesheet for the first animation
      dCol - the number of columns to offset into the spritesheet for the first animation