Class WheelObstacle

java.lang.Object
edu.cornell.gdiac.physics2.Obstacle
edu.cornell.gdiac.physics2.WheelObstacle

public class WheelObstacle extends Obstacle
Circle-shaped model to support collisions.

This class only supports circles, not ellipses. If you want an ellipse, you will have to use a PolygonObstacle. Unless otherwise specified, the center of mass is as the center.

  • Field Details

    • shape

      protected com.badlogic.gdx.physics.box2d.CircleShape shape
      Shape information for this circle
  • Constructor Details

    • WheelObstacle

      public WheelObstacle()
      Creates a new degenerate circle.

      This circle has no size, and so will not support collisions (e.g. it is only a body). You should setRadius(float) before activating this physics object.

    • WheelObstacle

      public WheelObstacle(float radius)
      Creates a new circle at the origin.

      The size is expressed in physics units NOT pixels. In order for drawing to work properly, you MUST call Obstacle.setPhysicsUnits(float).

      Parameters:
      radius - The wheel radius
    • WheelObstacle

      public WheelObstacle(float x, float y, float radius)
      Creates a new circle object.

      The size is expressed in physics units NOT pixels. In order for drawing to work properly, you MUST call Obstacle.setPhysicsUnits(float).

      Parameters:
      x - Initial x position of the circle center
      y - Initial y position of the circle center
      radius - The wheel radius
  • Method Details

    • getRadius

      public float getRadius()
      Returns the radius of this circle
      Returns:
      the radius of this circle
    • setRadius

      public void setRadius(float value)
      Sets the radius of this circle
      Parameters:
      value - the radius of this circle
    • getTolerance

      public float getTolerance()
      Returns the outline tolerance of this obstacle. In box2d, a wheel is a perfect circle. But we cannot draw perfect circles. As a result, the outline drawn in debug mode may not perfectly match the box2d fixture. This value defines that drawing tolerance. Lower values make a shape that is more circular (default value is 0.05). This value only affects debugging. It has no affect on box2d.
      Returns:
      the outline tolerance of this obstacle.
    • setTolerance

      public void setTolerance(float tolerance)
      Sets the outline tolerance of this obstacle. In box2d, a wheel is a perfect circle. But we cannot draw perfect circles. As a result, the outline drawn in debug mode may not perfectly match the box2d fixture. This value defines that drawing tolerance. Lower values make a shape that is more circular (default value is 0.05). This value only affects debugging. It has no affect on box2d.
      Parameters:
      tolerance - The outline tolerance of this obstacle.
    • createFixtures

      protected void createFixtures()
      Creates new fixtures for this body, defining the shape

      This is the primary method to override for custom physics objects

      Specified by:
      createFixtures in class Obstacle
    • releaseFixtures

      protected void releaseFixtures()
      Releases the fixtures for this body, reseting the shape

      This is the primary method to override for custom physics objects

      Specified by:
      releaseFixtures in class Obstacle