Class Interpolator

java.lang.Object
nl.saxion.gameapp.animation.Animatable<Float>
nl.saxion.gameapp.animation.Interpolator

public class Interpolator extends Animatable<Float>
Interpolates between two values over time using a specified strategy.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Interpolator(float start, float end, float duration, com.badlogic.gdx.math.Interpolation strategy)
    Creates an interpolator with a specific strategy.
    Interpolator(float start, float end, float duration, String strategyName)
    Creates an interpolator using a strategy name as a string.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String[]
    Returns all valid string names for interpolation strategies that are supported.
    float
     
    float
     
    float
     
    float
     
    boolean
    Find out if the interpolation has finished.
    void
    reset(boolean reverse)
    Resets the animation or interpolation to its initial state.
    update(float deltaTime)
    Updates the interpolator and returns the current value.

    Methods inherited from class nl.saxion.gameapp.animation.Animatable

    reset

    Methods inherited from class java.lang.Object

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

    • Interpolator

      public Interpolator(float start, float end, float duration, com.badlogic.gdx.math.Interpolation strategy)
      Creates an interpolator with a specific strategy.
      Parameters:
      start - starting value
      end - ending value
      duration - how long the interpolation takes in seconds
      strategy - the Interpolation to use
    • Interpolator

      public Interpolator(float start, float end, float duration, String strategyName)
      Creates an interpolator using a strategy name as a string. The string is case-insensitive.
      Parameters:
      start - starting value
      end - ending value
      duration - how long the interpolation takes in seconds
      strategyName - the name of the interpolation strategy
  • Method Details

    • update

      public Float update(float deltaTime)
      Updates the interpolator and returns the current value.
      Specified by:
      update in class Animatable<Float>
      Parameters:
      deltaTime - time since last update (seconds)
      Returns:
      current interpolated value
    • isFinished

      public boolean isFinished()
      Find out if the interpolation has finished.
      Specified by:
      isFinished in class Animatable<Float>
      Returns:
      True, if the interpolation has finished
    • reset

      public void reset(boolean reverse)
      Description copied from class: Animatable
      Resets the animation or interpolation to its initial state.

      Subclasses may implement the reverse flag to play the animation backward if desired.

      Specified by:
      reset in class Animatable<Float>
      Parameters:
      reverse - whether to reset in reverse mode (if supported)
    • getStart

      public float getStart()
    • getEnd

      public float getEnd()
    • getDuration

      public float getDuration()
    • getElapsed

      public float getElapsed()
    • getAllInterpolationNames

      public static String[] getAllInterpolationNames()
      Returns all valid string names for interpolation strategies that are supported.
      Returns:
      array of all interpolation names