Class Animation

java.lang.Object
com.xebisco.yield.Animation
All Implemented Interfaces:
Closeable, AutoCloseable

public class Animation extends Object implements Closeable
Represents an animation made up of multiple frames.
  • Constructor Details

    • Animation

      public Animation(AbstractTexture... frames)
      Constructor with looping enabled and 0.5-second delay.
      Parameters:
      frames - The frames of the animation.
    • Animation

      public Animation(boolean loop, double delay, AbstractTexture... frames)
      Constructor with customizable loop and delay.
      Parameters:
      loop - Whether the animation should loop.
      delay - The delay between frames in seconds.
      frames - The frames of the animation.
  • Method Details

    • close

      public void close() throws IOException
      Closes all frames of the animation.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - If an I/O error occurs.
    • frames

      public AbstractTexture[] frames()
      Returns the frames of the animation.
      Returns:
      The frames of the animation.
    • setFrames

      public Animation setFrames(AbstractTexture[] frames)
      Sets the frames of the animation.
      Parameters:
      frames - The new frames of the animation.
      Returns:
      This animation instance for chaining.
    • delay

      public double delay()
      Returns the delay between frames in seconds.
      Returns:
      The delay between frames in seconds.
    • setDelay

      public Animation setDelay(double delay)
      Sets the delay between frames in seconds.
      Parameters:
      delay - The new delay between frames in seconds.
      Returns:
      This animation instance for chaining.
    • loop

      public boolean loop()
      Returns whether the animation should loop.
      Returns:
      Whether the animation should loop.
    • setLoop

      public Animation setLoop(boolean loop)
      Sets whether the animation should loop.
      Parameters:
      loop - Whether the animation should loop.
      Returns:
      This animation instance for chaining.