public class Chain
extends java.lang.Object
segments and connections to simulate a chain. Also provides modification methods that use a Chain.Builder.| Modifier and Type | Class and Description |
|---|---|
static interface |
Chain.Builder
used by a
Chain to modify it |
static class |
Chain.Connection
holds one or more
joints |
static class |
Chain.CopyBuilder
|
static class |
Chain.DefBuilder
|
static class |
Chain.DefShapeBuilder
|
static class |
Chain.JointDefCopyBuilder
a
Chain.CopyBuilder that uses a JointDef in Chain.JointDefCopyBuilder.createConnection(Body, int, Body, int) |
| Modifier and Type | Field and Description |
|---|---|
private Chain.Builder |
builder
the
Chain.Builder used for modifications of this Chain |
private com.badlogic.gdx.utils.Array<Chain.Connection> |
connections
the
Joints of this Chain |
private com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Body> |
segments
the
segments of this Chain |
private com.badlogic.gdx.utils.Array<Chain.Connection> |
tmpConnections
Warning: This is used by multiple methods and may be modified unexpectedly.
|
private com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Body> |
tmpSegments
Warning: This is used by multiple methods and may be modified unexpectedly.
|
| Constructor and Description |
|---|
Chain(Chain.Builder builder) |
Chain(Chain.Builder builder,
com.badlogic.gdx.physics.box2d.Body... segments)
creates a new Chain with the given
segments |
Chain(Chain other)
creates a shallow copy of the given
Chain instance |
Chain(int length,
Chain.Builder builder)
creates a new Chain and
builds it to the given length |
Chain(int length,
Chain.Builder builder,
boolean build)
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(com.badlogic.gdx.physics.box2d.Body segment)
adds the given segment to the end of this Chain |
void |
addAll(com.badlogic.gdx.physics.box2d.Body... segments)
adds the given segments to the end of this Chain |
Chain.Connection |
createConnection(int segmentIndex1,
int segmentIndex2)
creates a new Chain.Connection |
Chain.Connection |
createConnection(int segmentIndex1,
int segmentIndex2,
Chain.Builder builder)
Creates a
Chain.Connection using the Chain.Builder passing the correct parameters to Chain.Builder.createConnection(Body, int, Body, int) specified by the given indices. |
com.badlogic.gdx.physics.box2d.Body |
createSegment(int index)
|
com.badlogic.gdx.physics.box2d.Body |
createSegment(int index,
Chain.Builder builder)
Creates a
segment using the given Chain.Builder passing the correct parameters to Chain.Builder.createSegment(int, int, Chain) specified by the given index. |
void |
destroy(com.badlogic.gdx.physics.box2d.Body segment) |
void |
destroy(int index) |
void |
destroy(int beginIndex,
int endIndex)
destroys all segments from beginIndex to endIndex |
com.badlogic.gdx.physics.box2d.Body |
extend()
|
com.badlogic.gdx.physics.box2d.Body |
extend(Chain.Builder builder)
|
Chain |
extend(int length)
|
Chain |
extend(int length,
Chain.Builder builder)
|
Chain.Builder |
getBuilder() |
Chain.Connection |
getConnection(int index) |
com.badlogic.gdx.utils.Array<Chain.Connection> |
getConnections()
Warning: The returned Array is used by other methods and may be modified unexpectedly.
|
com.badlogic.gdx.physics.box2d.Body |
getSegment(int index) |
com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Body> |
getSegments()
Warning: The returned Array is used by other methods and may be modified unexpectedly.
|
com.badlogic.gdx.physics.box2d.Body |
insert(int index)
|
void |
insert(int index,
com.badlogic.gdx.physics.box2d.Body segment)
inserts a
segment into this Chain |
int |
length() |
com.badlogic.gdx.physics.box2d.Body |
remove(com.badlogic.gdx.physics.box2d.Body segment) |
com.badlogic.gdx.physics.box2d.Body |
remove(int index)
removes a
segment from this Chain |
com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Body> |
remove(int beginIndex,
int endIndex)
removes all segmetns from beginIndex to endIndex |
com.badlogic.gdx.physics.box2d.Body |
replace(int index,
com.badlogic.gdx.physics.box2d.Body segment) |
void |
setBuilder(Chain.Builder builder) |
void |
shorten()
destorys the last segment |
void |
shorten(int length)
destroys the given amount of segments from the end of the Chain |
Chain |
split(Chain.Connection connection) |
Chain |
split(int connectionIndex)
splits this Chain at the given index and returns a new Chain consisting of the
segments up to the given index |
private Chain.Builder builder
Chain.Builder used for modifications of this Chainprivate final com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Body> segments
segments of this Chainprivate final com.badlogic.gdx.utils.Array<Chain.Connection> connections
Joints of this Chainprivate final com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Body> tmpSegments
add its items to your own collection.private final com.badlogic.gdx.utils.Array<Chain.Connection> tmpConnections
add its items to your own collection.public Chain(Chain other)
Chain instanceother - the Chain to copypublic Chain(Chain.Builder builder)
builder - the builderpublic Chain(int length,
Chain.Builder builder)
builds it to the given lengthlength - the desired length of this Chainbuilder - the builderChain(int, Builder, boolean)public Chain(int length,
Chain.Builder builder,
boolean build)
public Chain(Chain.Builder builder, com.badlogic.gdx.physics.box2d.Body... segments)
segmentspublic Chain extend(int length)
extend(int, Builder)public Chain extend(int length, Chain.Builder builder)
extend(Builder)public com.badlogic.gdx.physics.box2d.Body extend()
extend(Builder)public com.badlogic.gdx.physics.box2d.Body extend(Chain.Builder builder)
public void shorten()
destorys the last segmentpublic void shorten(int length)
destroys the given amount of segments from the end of the Chainpublic com.badlogic.gdx.physics.box2d.Body createSegment(int index)
createSegment(int, Builder)public com.badlogic.gdx.physics.box2d.Body createSegment(int index,
Chain.Builder builder)
segment using the given Chain.Builder passing the correct parameters to Chain.Builder.createSegment(int, int, Chain) specified by the given index. Does NOT add it to this Chain.public Chain.Connection createConnection(int segmentIndex1, int segmentIndex2)
creates a new Chain.ConnectioncreateConnection(int, int, Builder)public Chain.Connection createConnection(int segmentIndex1, int segmentIndex2, Chain.Builder builder)
Chain.Connection using the Chain.Builder passing the correct parameters to Chain.Builder.createConnection(Body, int, Body, int) specified by the given indices. Does NOT add it to this Chain.public void add(com.badlogic.gdx.physics.box2d.Body segment)
adds the given segment to the end of this Chainsegment - the segment to addpublic void addAll(com.badlogic.gdx.physics.box2d.Body... segments)
adds the given segments to the end of this Chainadd(Body)public com.badlogic.gdx.physics.box2d.Body insert(int index)
insert(int, Body)public void insert(int index,
com.badlogic.gdx.physics.box2d.Body segment)
segment into this Chainindex - the index at which to insert the given segmentsegment - the segment to insertpublic com.badlogic.gdx.physics.box2d.Body replace(int index,
com.badlogic.gdx.physics.box2d.Body segment)
index - the index of the segment to replacesegment - the segment to insertsegment that was at the given index previouslypublic com.badlogic.gdx.physics.box2d.Body remove(com.badlogic.gdx.physics.box2d.Body segment)
segment - The Body to remove. Must be a segment of this Chain.bodyremove(int)public com.badlogic.gdx.physics.box2d.Body remove(int index)
segment from this Chainpublic com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Body> remove(int beginIndex,
int endIndex)
removes all segmetns from beginIndex to endIndexbeginIndex - the first index to removeendIndex - the last index to removetmpSegmentspublic void destroy(com.badlogic.gdx.physics.box2d.Body segment)
segment - the segment to destroydestroy(int)public void destroy(int index)
index - the index of the segment to destroyremove(int)public void destroy(int beginIndex,
int endIndex)
destroys all segments from beginIndex to endIndexbeginIndex - the first index to destroyendIndex - the last index to destroypublic Chain split(Chain.Connection connection)
connection - the Chain.Connection in connections to splitChainsplit(int)public Chain split(int connectionIndex)
segments up to the given indexconnectionIndex - the index of the connection to destroypublic int length()
segments in this ChainArray.sizepublic com.badlogic.gdx.physics.box2d.Body getSegment(int index)
index - the index of the desired segmentsegment at the given indexpublic Chain.Connection getConnection(int index)
public com.badlogic.gdx.utils.Array<com.badlogic.gdx.physics.box2d.Body> getSegments()
add its items to your own collection.segmentstmpSegmentspublic com.badlogic.gdx.utils.Array<Chain.Connection> getConnections()
add its items to your own collection.connectionstmpConnectionspublic Chain.Builder getBuilder()
builderpublic void setBuilder(Chain.Builder builder)
builder - the builder to set