Class VectorGlider

java.lang.Object
com.github.yellowstonegames.smooth.Glider
com.github.yellowstonegames.smooth.VectorGlider

public class VectorGlider extends Glider
Allows specifying a smoothly-changing float position using a libGDX Vector2 for the start and the end, with a change amount that affects how far a position has moved from start to end. Typical usage sets the start with setStart(Vector2) once and the end more than once with setEnd(Vector2), changing the end each time the move is complete. The x and y positions are automatically calculated in getX() and getY(), and their values will be different every time Glider.setChange(float) is called with a different amount. You can optionally use an Interpolation to make the rate of change different.
This is extremely similar to CoordGlider, but instead of locking positions to integer coordinates, this allows movement to non-integer positions. This should be useful for small movements like shaking or bumping.
This is a type of Glider, and so is compatible with other Gliders (it can also be merged with them).
  • Field Details

    • start

      protected com.badlogic.gdx.math.Vector2 start
    • end

      protected com.badlogic.gdx.math.Vector2 end
  • Constructor Details

    • VectorGlider

      public VectorGlider()
    • VectorGlider

      public VectorGlider(com.badlogic.gdx.math.Vector2 end)
      Assigns Vector2.Zero into start and end into end; does not continue to use the reference to the parameter end, or Zero.
      Parameters:
      end - will be copied into end
    • VectorGlider

      public VectorGlider(com.badlogic.gdx.math.Vector2 start, com.badlogic.gdx.math.Vector2 end)
      Copies start into start and end into end; does not continue to use references to the parameters.
      Parameters:
      start - will be copied into start
      end - will be copied into end
    • VectorGlider

      public VectorGlider(com.badlogic.gdx.math.Vector2 start, com.badlogic.gdx.math.Vector2 end, com.github.tommyettinger.digital.Interpolations.Interpolator interpolation, Runnable completeRunner)
      Copies start into start and end into end; does not continue to use references to the parameters.
      Parameters:
      start - will be copied into start
      end - will be copied into end
      interpolation - how to interpolate from start to end; typically a constant from Interpolation
      completeRunner - a Runnable that, if non-null, will be run when the glide completes
    • VectorGlider

      public VectorGlider(VectorGlider other)
    • VectorGlider

      public VectorGlider(Glider other)
  • Method Details

    • getX

      public float getX()
    • getY

      public float getY()
    • getStart

      public com.badlogic.gdx.math.Vector2 getStart()
    • setStart

      public void setStart(com.badlogic.gdx.math.Vector2 start)
    • getEnd

      public com.badlogic.gdx.math.Vector2 getEnd()
    • setEnd

      public void setEnd(com.badlogic.gdx.math.Vector2 end)
    • onComplete

      public void onComplete()
      Overrides:
      onComplete in class Glider
    • toString

      public String toString()
      Overrides:
      toString in class Object