Package net.dermetfan.gdx.physics.box2d
Class Breakable
java.lang.Object
net.dermetfan.gdx.physics.box2d.Breakable
Breaks bodies or fixtures if they get hit too hard. Put in fixture's or body's user data and set
Don't forget to call
You can manually destroy fixtures or bodies using the
Breakable.Manager as ContactListener.Don't forget to call
Breakable.Manager.destroy() after every world time step.You can manually destroy fixtures or bodies using the
Breakable.Manager.destroy(Fixture) and Breakable.Manager.destroy(Body) methods.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacea callback for aBreakableif its container (body or fixture) was destroyed (for example to play a sound)static classManages theBreakablesof the Contacts it receives. -
Constructor Summary
ConstructorsConstructorDescriptionBreakable(float normalResistance, float tangentResistance) Breakable(float normalResistance, float tangentResistance, boolean breakBody) Breakable(float normalResistance, float tangentResistance, boolean breakBody, boolean breakBodyWithoutFixtures) Breakable(float normalResistance, float tangentResistance, boolean breakBody, Breakable.Callback callback) Breakable(float normalResistance, float tangentResistance, com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance, boolean breakBody, boolean breakBodyWithoutFixtures, Breakable.Callback callback) Breakable(float normalResistance, float tangentResistance, Breakable.Callback callback) Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance) Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance, boolean breakBody) Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance, boolean breakBody, boolean breakBodyWithoutFixtures) Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance, boolean breakBody, Breakable.Callback callback) Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance, Breakable.Callback callback) constructs a new Breakable exactly like the given other one -
Method Summary
Modifier and TypeMethodDescriptionfloatfloatcom.badlogic.gdx.math.Vector2floatfloatbooleanbooleanvoidsetBreakBody(boolean breakBody) voidsetBreakBodyWithoutFixtures(boolean breakBodyWithoutFixtures) voidsetCallback(Breakable.Callback callback) voidsetNormalResistance(float normalResistance) voidsetReactionForceLength2Resistance(float reactionForceLength2Resistance) voidsetReactionForceResistance(com.badlogic.gdx.math.Vector2 reactionForceResistance) voidsetReactionTorqueResistance(float reactionTorqueResistance) voidsetTangentResistance(float tangentResistance)
-
Constructor Details
-
Breakable
public Breakable(float normalResistance, float tangentResistance) - See Also:
-
Breakable
public Breakable(float normalResistance, float tangentResistance, boolean breakBody) - See Also:
-
Breakable
public Breakable(float normalResistance, float tangentResistance, boolean breakBody, boolean breakBodyWithoutFixtures) - See Also:
-
Breakable
- See Also:
-
Breakable
public Breakable(float normalResistance, float tangentResistance, boolean breakBody, Breakable.Callback callback) - See Also:
-
Breakable
public Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance) - See Also:
-
Breakable
public Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance, boolean breakBody) - See Also:
-
Breakable
public Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance, boolean breakBody, boolean breakBodyWithoutFixtures) - See Also:
-
Breakable
public Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance, Breakable.Callback callback) - See Also:
-
Breakable
public Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance, boolean breakBody, Breakable.Callback callback) - See Also:
-
Breakable
public Breakable(float normalResistance, float tangentResistance, com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance, boolean breakBody, boolean breakBodyWithoutFixtures, Breakable.Callback callback) - Parameters:
normalResistance- thenormalResistancetangentResistance- thetangentResistancereactionForceResistance- thereactionForceResistancereactionForceLength2Resistance- thereactionForceLength2ResistancereactionTorqueResistance- thereactionTorqueResistancebreakBody- thebreakBodybreakBodyWithoutFixtures- thebreakBodyWithoutFixturescallback- thecallback
-
Breakable
constructs a new Breakable exactly like the given other one
-
-
Method Details
-
getNormalResistance
public float getNormalResistance()- Returns:
- the
normalResistance
-
setNormalResistance
public void setNormalResistance(float normalResistance) - Parameters:
normalResistance- thenormalResistanceto set
-
getTangentResistance
public float getTangentResistance()- Returns:
- the
tangentResistance
-
setTangentResistance
public void setTangentResistance(float tangentResistance) - Parameters:
tangentResistance- thetangentResistanceto set
-
getReactionForceResistance
public com.badlogic.gdx.math.Vector2 getReactionForceResistance()- Returns:
- the
reactionForceResistance
-
setReactionForceResistance
public void setReactionForceResistance(com.badlogic.gdx.math.Vector2 reactionForceResistance) - Parameters:
reactionForceResistance- thereactionForceResistanceto set
-
getReactionForceLength2Resistance
public float getReactionForceLength2Resistance()- Returns:
- the
reactionForceLength2Resistance
-
setReactionForceLength2Resistance
public void setReactionForceLength2Resistance(float reactionForceLength2Resistance) - Parameters:
reactionForceLength2Resistance- thereactionForceLength2Resistanceto set
-
getReactionTorqueResistance
public float getReactionTorqueResistance()- Returns:
- the
reactionTorqueResistance
-
setReactionTorqueResistance
public void setReactionTorqueResistance(float reactionTorqueResistance) - Parameters:
reactionTorqueResistance- thereactionTorqueResistanceto set
-
isBreakBody
public boolean isBreakBody()- Returns:
- the
breakBody
-
setBreakBody
public void setBreakBody(boolean breakBody) - Parameters:
breakBody- thebreakBodyto set
-
isBreakBodyWithoutFixtures
public boolean isBreakBodyWithoutFixtures()- Returns:
- the
breakBodyWithoutFixtures
-
setBreakBodyWithoutFixtures
public void setBreakBodyWithoutFixtures(boolean breakBodyWithoutFixtures) - Parameters:
breakBodyWithoutFixtures- thebreakBodyWithoutFixturesto set
-
getCallback
- Returns:
- the
callback
-
setCallback
- Parameters:
callback- thecallbackto set
-