Package net.dermetfan.gdx.physics.box2d
Class Breakable.Manager
java.lang.Object
net.dermetfan.gdx.physics.box2d.Breakable.Manager
- All Implemented Interfaces:
 com.badlogic.gdx.physics.box2d.ContactListener
- Enclosing class:
 - Breakable
 
public static class Breakable.Manager
extends java.lang.Object
implements com.badlogic.gdx.physics.box2d.ContactListener
Manages the 
Breakables of the Contacts it receives. Do not forget to set as ContactListener and to call destroy() after every world step.- 
Field Summary
Fields Modifier and Type Field Description com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Body>brokenBodiesthe bodies that broke instrain(Contact, ContactImpulse)com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Fixture>brokenFixturesthe fixtures that broke instrain(Contact, ContactImpulse)com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Joint>brokenJointsthe joints that broke instrain(Joint, float)static net.dermetfan.utils.Function<java.lang.Object,Breakable>defaultUserDataAccessortheuserDataAccessorused by default - 
Constructor Summary
Constructors Constructor Description Manager()instantiates a newBreakable.ManagerManager(net.dermetfan.utils.Function<java.lang.Object,Breakable> userDataAccessor)instantiates a newBreakable.Managerwith the givenuserDataAccessor - 
Method Summary
Modifier and Type Method Description voidbeginContact(com.badlogic.gdx.physics.box2d.Contact contact)does nothingvoiddestroy()actually destroys all bodies inbrokenBodiesand fixtures inbrokenFixturesvoiddestroy(com.badlogic.gdx.physics.box2d.Body body)voiddestroy(com.badlogic.gdx.physics.box2d.Fixture fixture)destroys the given fixture (and its body depending onBreakable.breakBodyWithoutFixturesandBreakable.breakBody)voiddestroy(com.badlogic.gdx.physics.box2d.Joint joint)voidendContact(com.badlogic.gdx.physics.box2d.Contact contact)does nothingcom.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Body>getBrokenBodies()com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Fixture>getBrokenFixtures()net.dermetfan.utils.Function<java.lang.Object,Breakable>getUserDataAccessor()voidpostSolve(com.badlogic.gdx.physics.box2d.Contact contact, com.badlogic.gdx.physics.box2d.ContactImpulse impulse)voidpreSolve(com.badlogic.gdx.physics.box2d.Contact contact, com.badlogic.gdx.physics.box2d.Manifold oldManifold)does nothingvoidsetUserDataAccessor(net.dermetfan.utils.Function<java.lang.Object,Breakable> userDataAccessor)static booleanshouldBreak(Breakable breakable, float normalImpulse, float tangentImpulse, com.badlogic.gdx.physics.box2d.Contact contact, com.badlogic.gdx.physics.box2d.ContactImpulse impulse, com.badlogic.gdx.physics.box2d.Fixture fixture)static booleanshouldBreak(Breakable breakable, com.badlogic.gdx.math.Vector2 reactionForce, float reactionTorque, com.badlogic.gdx.physics.box2d.Joint joint)voidstrain(com.badlogic.gdx.physics.box2d.Contact contact, com.badlogic.gdx.physics.box2d.ContactImpulse impulse)voidstrain(com.badlogic.gdx.physics.box2d.Joint joint, float delta)voidstrain(com.badlogic.gdx.physics.box2d.World world, float delta)strainsall joints in the given worldMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait 
- 
Field Details
- 
brokenFixtures
public final com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Fixture> brokenFixturesthe fixtures that broke instrain(Contact, ContactImpulse) - 
brokenBodies
public final com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Body> brokenBodiesthe bodies that broke instrain(Contact, ContactImpulse) - 
brokenJoints
public final com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Joint> brokenJointsthe joints that broke instrain(Joint, float) - 
defaultUserDataAccessor
public static final net.dermetfan.utils.Function<java.lang.Object,Breakable> defaultUserDataAccessortheuserDataAccessorused by default 
 - 
 - 
Constructor Details
- 
Manager
public Manager()instantiates a newBreakable.Manager - 
Manager
instantiates a newBreakable.Managerwith the givenuserDataAccessor 
 - 
 - 
Method Details
- 
destroy
public void destroy()actually destroys all bodies inbrokenBodiesand fixtures inbrokenFixtures - 
strain
public void strain(com.badlogic.gdx.physics.box2d.Contact contact, com.badlogic.gdx.physics.box2d.ContactImpulse impulse) - 
strain
public void strain(com.badlogic.gdx.physics.box2d.World world, float delta)strainsall joints in the given world - 
strain
public void strain(com.badlogic.gdx.physics.box2d.Joint joint, float delta) - 
shouldBreak
public static boolean shouldBreak(Breakable breakable, float normalImpulse, float tangentImpulse, com.badlogic.gdx.physics.box2d.Contact contact, com.badlogic.gdx.physics.box2d.ContactImpulse impulse, com.badlogic.gdx.physics.box2d.Fixture fixture)- Parameters:
 contact- forBreakable.Callback.strained(Fixture, Breakable, Contact, ContactImpulse, float, float)impulse- forBreakable.Callback.strained(Fixture, Breakable, Contact, ContactImpulse, float, float)fixture- forBreakable.Callback.strained(Fixture, Breakable, Contact, ContactImpulse, float, float)- Returns:
 - if the fixtures and bodies involved in the given contact should break under the given circumstances
 
 - 
shouldBreak
public static boolean shouldBreak(Breakable breakable, com.badlogic.gdx.math.Vector2 reactionForce, float reactionTorque, com.badlogic.gdx.physics.box2d.Joint joint)- Parameters:
 reactionForce- thereaction forcereactionTorque- thereaction torquejoint- which circumstances to test- Returns:
 - if the joint strained with the given values should break
 
 - 
destroy
public void destroy(com.badlogic.gdx.physics.box2d.Fixture fixture)destroys the given fixture (and its body depending onBreakable.breakBodyWithoutFixturesandBreakable.breakBody)- Parameters:
 fixture- theFixtureto destroy
 - 
destroy
public void destroy(com.badlogic.gdx.physics.box2d.Body body)- Parameters:
 body- theBodyto destroy
 - 
destroy
public void destroy(com.badlogic.gdx.physics.box2d.Joint joint)- Parameters:
 joint- theJointto destroy
 - 
beginContact
public void beginContact(com.badlogic.gdx.physics.box2d.Contact contact)does nothing- Specified by:
 beginContactin interfacecom.badlogic.gdx.physics.box2d.ContactListener
 - 
preSolve
public void preSolve(com.badlogic.gdx.physics.box2d.Contact contact, com.badlogic.gdx.physics.box2d.Manifold oldManifold)does nothing- Specified by:
 preSolvein interfacecom.badlogic.gdx.physics.box2d.ContactListener
 - 
postSolve
public void postSolve(com.badlogic.gdx.physics.box2d.Contact contact, com.badlogic.gdx.physics.box2d.ContactImpulse impulse)- Specified by:
 postSolvein interfacecom.badlogic.gdx.physics.box2d.ContactListener
 - 
endContact
public void endContact(com.badlogic.gdx.physics.box2d.Contact contact)does nothing- Specified by:
 endContactin interfacecom.badlogic.gdx.physics.box2d.ContactListener
 - 
getBrokenFixtures
public com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Fixture> getBrokenFixtures()- Returns:
 - the 
brokenFixtures 
 - 
getBrokenBodies
public com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Body> getBrokenBodies()- Returns:
 - the 
brokenBodies 
 - 
getUserDataAccessor
- Returns:
 - the 
userDataAccessor 
 - 
setUserDataAccessor
public void setUserDataAccessor(net.dermetfan.utils.Function<java.lang.Object,Breakable> userDataAccessor)- Parameters:
 userDataAccessor- theuserDataAccessorto set
 
 -