Class WheelObstacle
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 Summary
FieldsModifier and TypeFieldDescriptionprotected com.badlogic.gdx.physics.box2d.CircleShapeShape information for this circleFields inherited from class edu.cornell.gdiac.physics2.Obstacle
body, bodyinfo, centroidCache, DEFAULT_UNITS, fixture, massdata, masseffect, outline, positionCache, transform, units, velocityCache -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new degenerate circle.WheelObstacle(float radius) Creates a new circle at the origin.WheelObstacle(float x, float y, float radius) Creates a new circle object. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCreates new fixtures for this body, defining the shapefloatReturns the radius of this circlefloatReturns the outline tolerance of this obstacle.protected voidReleases the fixtures for this body, reseting the shapevoidsetRadius(float value) Sets the radius of this circlevoidsetTolerance(float tolerance) Sets the outline tolerance of this obstacle.Methods inherited from class edu.cornell.gdiac.physics2.Obstacle
activatePhysics, deactivatePhysics, draw, draw, draw, draw, getAngle, getAngularDamping, getAngularVelocity, getBody, getBodyType, getCentroid, getDensity, getFilterData, getFriction, getGravityScale, getInertia, getLinearDamping, getLinearVelocity, getMass, getName, getOutline, getPhysicsUnits, getPosition, getRestitution, getUserData, getVX, getVY, getX, getY, isActive, isAwake, isBullet, isDirty, isFixedRotation, isRemoved, isSensor, isSleepingAllowed, markDirty, markRemoved, resetMass, setActive, setAngle, setAngularDamping, setAngularVelocity, setAwake, setBodyState, setBodyType, setBullet, setCentroid, setDensity, setFilterData, setFixedRotation, setFriction, setGravityScale, setInertia, setLinearDamping, setLinearVelocity, setMass, setName, setPhysicsUnits, setPosition, setPosition, setRestitution, setSensor, setSleepingAllowed, setUserData, setVX, setVY, setX, setY, update
-
Field Details
-
shape
protected com.badlogic.gdx.physics.box2d.CircleShape shapeShape 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 centery- Initial y position of the circle centerradius- 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 shapeThis is the primary method to override for custom physics objects
- Specified by:
createFixturesin classObstacle
-
releaseFixtures
protected void releaseFixtures()Releases the fixtures for this body, reseting the shapeThis is the primary method to override for custom physics objects
- Specified by:
releaseFixturesin classObstacle
-