libgdx API

com.badlogic.gdx.physics.box2d
Class Fixture

java.lang.Object
  extended by com.badlogic.gdx.physics.box2d.Fixture

public class Fixture
extends java.lang.Object


Field Summary
protected  long addr
          the address of the fixture
protected  Shape shape
          the shape, initialized lazy
protected  java.lang.Object userData
          user specified data
 
Constructor Summary
protected Fixture(Body body, long addr)
          Constructs a new fixture
 
Method Summary
 Body getBody()
          Get the parent body of this fixture.
 float getDensity()
          Get the density of this fixture.
 Filter getFilterData()
           
 float getFriction()
          Get the coefficient of friction.
 float getRestitution()
          Get the coefficient of restitution.
 Shape getShape()
          Returns the shape of this fixture
 Shape.Type getType()
          Get the type of the child shape.
 java.lang.Object getUserData()
           
 boolean isSensor()
          Is this fixture a sensor (non-solid)?
 void refilter()
          Call this if you want to establish collision that was previously disabled by b2ContactFilter::ShouldCollide.
protected  void reset(Body body, long addr)
           
 void setDensity(float density)
          Set the density of this fixture.
 void setFilterData(Filter filter)
          Set the contact filtering data.
 void setFriction(float friction)
          Set the coefficient of friction.
 void setRestitution(float restitution)
          Set the coefficient of restitution.
 void setSensor(boolean sensor)
          Set if this fixture is a sensor.
 void setUserData(java.lang.Object userData)
          Sets custom user data.
 boolean testPoint(float x, float y)
          Test a point for containment in this fixture.
 boolean testPoint(Vector2 p)
          Test a point for containment in this fixture.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

addr

protected long addr
the address of the fixture


shape

protected Shape shape
the shape, initialized lazy


userData

protected java.lang.Object userData
user specified data

Constructor Detail

Fixture

protected Fixture(Body body,
                  long addr)
Constructs a new fixture

Parameters:
addr - the address of the fixture
Method Detail

reset

protected void reset(Body body,
                     long addr)

getType

public Shape.Type getType()
Get the type of the child shape. You can use this to down cast to the concrete shape.

Returns:
the shape type.

getShape

public Shape getShape()
Returns the shape of this fixture


setSensor

public void setSensor(boolean sensor)
Set if this fixture is a sensor.


isSensor

public boolean isSensor()
Is this fixture a sensor (non-solid)?

Returns:
the true if the shape is a sensor.

setFilterData

public void setFilterData(Filter filter)
Set the contact filtering data. This will not update contacts until the next time step when either parent body is active and awake. This automatically calls Refilter.


getFilterData

public Filter getFilterData()

refilter

public void refilter()
Call this if you want to establish collision that was previously disabled by b2ContactFilter::ShouldCollide.


getBody

public Body getBody()
Get the parent body of this fixture. This is NULL if the fixture is not attached.


testPoint

public boolean testPoint(Vector2 p)
Test a point for containment in this fixture.

Parameters:
p - a point in world coordinates.

testPoint

public boolean testPoint(float x,
                         float y)
Test a point for containment in this fixture.

Parameters:
x - the x-coordinate
y - the y-coordinate

setDensity

public void setDensity(float density)
Set the density of this fixture. This will _not_ automatically adjust the mass of the body. You must call b2Body::ResetMassData to update the body's mass.


getDensity

public float getDensity()
Get the density of this fixture.


getFriction

public float getFriction()
Get the coefficient of friction.


setFriction

public void setFriction(float friction)
Set the coefficient of friction.


getRestitution

public float getRestitution()
Get the coefficient of restitution.


setRestitution

public void setRestitution(float restitution)
Set the coefficient of restitution.


setUserData

public void setUserData(java.lang.Object userData)
Sets custom user data.


getUserData

public java.lang.Object getUserData()
Returns:
custom user data

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)