Class GravityForce

java.lang.Object
de.gurkenlabs.litiengine.physics.Force
de.gurkenlabs.litiengine.physics.GravityForce

public class GravityForce extends Force
GravityForce is a gravitational force pulling entities towards a given direction or angle.
  • Constructor Details

    • GravityForce

      public GravityForce(IEntity forceEntity, float strength, Direction direction)
      Instantiates a new GravityForce.
      Parameters:
      forceEntity - The entity on which the gravitational force is applied.
      strength - The strength of the gravitational force.
      direction - The direction of the gravitational force.
    • GravityForce

      public GravityForce(IEntity forceEntity, float strength, float angle)
      Instantiates a new GravityForce.
      Parameters:
      forceEntity - The entity on which the gravitational force is applied.
      strength - The strength of the gravitational force.
      angle - The angle at which the gravitational force is applied.
  • Method Details

    • getForceEntity

      public IEntity getForceEntity()
      Gets the entity on which the gravitational force is applied.
      Returns:
      The force entity.
    • getLocation

      public Point2D getLocation()
      Calculates and returns the location where the gravitational force is applied. This location is calculated by projecting the force onto a point based on the entity's center, angle, and strength.
      Overrides:
      getLocation in class Force
      Returns:
      The location where the gravitational force is applied.