Package doodlepad

Class Throttle

java.lang.Object
doodlepad.Throttle

public class Throttle extends Object
A class that attempts to smooth out looping animation by measuring and executing the appropriate delay between frames.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor.
    Throttle(long fps)
    Constructor that allows frame rate to be set.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Compute the amount of time remaining in the current frame duration and sleep until the next frame begins.
    void
    Reset the start time, which is used to measure frame duration.

    Methods inherited from class java.lang.Object

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

    • Throttle

      public Throttle()
      Default constructor. Set frame rate to 60 frames per second.
    • Throttle

      public Throttle(long fps)
      Constructor that allows frame rate to be set.
      Parameters:
      fps - Frames per second
  • Method Details

    • start

      public void start()
      Reset the start time, which is used to measure frame duration.
    • delay

      public void delay()
      Compute the amount of time remaining in the current frame duration and sleep until the next frame begins.