Package net.dermetfan.gdx.physics.box2d
Class Breakable
java.lang.Object
net.dermetfan.gdx.physics.box2d.Breakable
public class Breakable
extends java.lang.Object
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 Classes Modifier and Type Class Description static interface
Breakable.Callback
a callback for aBreakable
if its container (body or fixture) was destroyed (for example to play a sound)static class
Breakable.Manager
Manages theBreakables
of the Contacts it receives. -
Constructor Summary
Constructors Constructor Description Breakable(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)
Breakable(Breakable other)
constructs a new Breakable exactly like the given other one -
Method Summary
Modifier and Type Method Description Breakable.Callback
getCallback()
float
getNormalResistance()
float
getReactionForceLength2Resistance()
com.badlogic.gdx.math.Vector2
getReactionForceResistance()
float
getReactionTorqueResistance()
float
getTangentResistance()
boolean
isBreakBody()
boolean
isBreakBodyWithoutFixtures()
void
setBreakBody(boolean breakBody)
void
setBreakBodyWithoutFixtures(boolean breakBodyWithoutFixtures)
void
setCallback(Breakable.Callback callback)
void
setNormalResistance(float normalResistance)
void
setReactionForceLength2Resistance(float reactionForceLength2Resistance)
void
setReactionForceResistance(com.badlogic.gdx.math.Vector2 reactionForceResistance)
void
setReactionTorqueResistance(float reactionTorqueResistance)
void
setTangentResistance(float tangentResistance)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
Breakable
public Breakable(float normalResistance, float tangentResistance)- See Also:
Breakable(float, float, boolean)
-
Breakable
public Breakable(float normalResistance, float tangentResistance, boolean breakBody) -
Breakable
public Breakable(float normalResistance, float tangentResistance, boolean breakBody, boolean breakBodyWithoutFixtures) -
Breakable
-
Breakable
public Breakable(float normalResistance, float tangentResistance, boolean breakBody, Breakable.Callback callback) -
Breakable
public Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance) -
Breakable
public Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance, boolean breakBody) -
Breakable
public Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance, boolean breakBody, boolean breakBodyWithoutFixtures) -
Breakable
public Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance, Breakable.Callback callback) -
Breakable
public Breakable(com.badlogic.gdx.math.Vector2 reactionForceResistance, float reactionForceLength2Resistance, float reactionTorqueResistance, boolean breakBody, Breakable.Callback callback) -
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
- thenormalResistance
tangentResistance
- thetangentResistance
reactionForceResistance
- thereactionForceResistance
reactionForceLength2Resistance
- thereactionForceLength2Resistance
reactionTorqueResistance
- thereactionTorqueResistance
breakBody
- thebreakBody
breakBodyWithoutFixtures
- thebreakBodyWithoutFixtures
callback
- 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
- thenormalResistance
to set
-
getTangentResistance
public float getTangentResistance()- Returns:
- the
tangentResistance
-
setTangentResistance
public void setTangentResistance(float tangentResistance)- Parameters:
tangentResistance
- thetangentResistance
to set
-
getReactionForceResistance
public com.badlogic.gdx.math.Vector2 getReactionForceResistance()- Returns:
- the
reactionForceResistance
-
setReactionForceResistance
public void setReactionForceResistance(com.badlogic.gdx.math.Vector2 reactionForceResistance)- Parameters:
reactionForceResistance
- thereactionForceResistance
to set
-
getReactionForceLength2Resistance
public float getReactionForceLength2Resistance()- Returns:
- the
reactionForceLength2Resistance
-
setReactionForceLength2Resistance
public void setReactionForceLength2Resistance(float reactionForceLength2Resistance)- Parameters:
reactionForceLength2Resistance
- thereactionForceLength2Resistance
to set
-
getReactionTorqueResistance
public float getReactionTorqueResistance()- Returns:
- the
reactionTorqueResistance
-
setReactionTorqueResistance
public void setReactionTorqueResistance(float reactionTorqueResistance)- Parameters:
reactionTorqueResistance
- thereactionTorqueResistance
to set
-
isBreakBody
public boolean isBreakBody()- Returns:
- the
breakBody
-
setBreakBody
public void setBreakBody(boolean breakBody)- Parameters:
breakBody
- thebreakBody
to set
-
isBreakBodyWithoutFixtures
public boolean isBreakBodyWithoutFixtures()- Returns:
- the
breakBodyWithoutFixtures
-
setBreakBodyWithoutFixtures
public void setBreakBodyWithoutFixtures(boolean breakBodyWithoutFixtures)- Parameters:
breakBodyWithoutFixtures
- thebreakBodyWithoutFixtures
to set
-
getCallback
- Returns:
- the
callback
-
setCallback
- Parameters:
callback
- thecallback
to set
-