Class PositionController

java.lang.Object
net.dermetfan.gdx.physics.box2d.PositionController
Direct Known Subclasses:
PositionController.D, PositionController.P, PositionController.PD

public abstract class PositionController extends Object
moves a body to a position using forces
Since:
0.11.1
  • Field Details

    • vec2

      protected static final com.badlogic.gdx.math.Vector2 vec2
      shared instance for internal use
    • defaultUserDataAccessor

      public static final net.dermetfan.utils.Function<Object,PositionController> defaultUserDataAccessor
      returns the argument if it is a PositionController
  • Constructor Details

    • PositionController

      public PositionController()
  • Method Details

    • applyForceToCenter

      public static void applyForceToCenter(com.badlogic.gdx.physics.box2d.World world, boolean wake)
      Calls applyForceToCenter for every Body with a PositionController in its user data. The PositionController is accessed using the userDataAccessor.
      Parameters:
      world - the world which Bodies to iterate over
    • calculateForce

      public abstract com.badlogic.gdx.math.Vector2 calculateForce(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 point)
      Parameters:
      point - the world point at which the force should be applied
      Returns:
      the force to apply at the given point
    • calculateForceToCenter

      public abstract com.badlogic.gdx.math.Vector2 calculateForceToCenter(com.badlogic.gdx.physics.box2d.Body body)
      Returns:
      the force to apply at the center of mass of the Body
    • applyForce

      public com.badlogic.gdx.math.Vector2 applyForce(com.badlogic.gdx.physics.box2d.Body body, com.badlogic.gdx.math.Vector2 point, boolean wake)
      applies the necessary force at the given point
      Parameters:
      point - the world point at which to apply the force
      Returns:
      the force applied, calculated by calculateForce(Body, Vector2)
    • applyForceToCenter

      public com.badlogic.gdx.math.Vector2 applyForceToCenter(com.badlogic.gdx.physics.box2d.Body body, boolean wake)
      applies the necessary force at the center of mass of the Body
      Returns:
      the force applied, calculated by calculateForceToCenter(Body)
    • getUserDataAccessor

      public static net.dermetfan.utils.Function<Object,PositionController> getUserDataAccessor()
      Returns:
      the userDataAccessor
    • setUserDataAccessor

      public static void setUserDataAccessor(net.dermetfan.utils.Function<Object,PositionController> userDataAccessor)
      Parameters:
      userDataAccessor - The userDataAccessor to set. If null, defaultUserDataAccessor is set.