Class Chain.DefShapeBuilder

java.lang.Object
net.dermetfan.gdx.physics.box2d.Chain.DefShapeBuilder
All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable, Chain.Builder
Enclosing class:
Chain

public static class Chain.DefShapeBuilder
extends java.lang.Object
implements Chain.Builder, com.badlogic.gdx.utils.Disposable
A Chain.Builder that builds using a BodyDef, JointDef and Shape. Should be dispose if no longer used.
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected com.badlogic.gdx.physics.box2d.BodyDef bodyDef
    the BodyDef to use in createSegment(int, int, Chain)
    protected float density
    the density to use in Body.createFixture(Shape, float)
    protected com.badlogic.gdx.physics.box2d.JointDef jointDef
    the JointDef to use in createSegment(int, int, Chain)
    protected com.badlogic.gdx.physics.box2d.Shape shape
    the Shape to use in createSegment(int, int, Chain)
    protected com.badlogic.gdx.physics.box2d.World world
    the World to create things in
  • Constructor Summary

    Constructors
    Constructor Description
    DefShapeBuilder​(com.badlogic.gdx.physics.box2d.World world, com.badlogic.gdx.physics.box2d.BodyDef bodyDef, com.badlogic.gdx.physics.box2d.Shape shape, float density, com.badlogic.gdx.physics.box2d.JointDef jointDef)  
  • Method Summary

    Modifier and Type Method Description
    Chain.Connection createConnection​(com.badlogic.gdx.physics.box2d.Body seg1, int seg1index, com.badlogic.gdx.physics.box2d.Body seg2, int seg2index)
    connects two segments with each other using a Chain.Connection
    com.badlogic.gdx.physics.box2d.Body createSegment​(int index, int length, Chain chain)
    creates a segment using bodyDef, shape and density
    void dispose()
    disposes the shape
    com.badlogic.gdx.physics.box2d.BodyDef getBodyDef()  
    float getDensity()  
    com.badlogic.gdx.physics.box2d.JointDef getJointDef()  
    com.badlogic.gdx.physics.box2d.Shape getShape()  
    com.badlogic.gdx.physics.box2d.World getWorld()  
    void setBodyDef​(com.badlogic.gdx.physics.box2d.BodyDef bodyDef)  
    void setDensity​(float density)  
    void setJointDef​(com.badlogic.gdx.physics.box2d.JointDef jointDef)  
    void setWorld​(com.badlogic.gdx.physics.box2d.World world)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • world

      protected com.badlogic.gdx.physics.box2d.World world
      the World to create things in
    • bodyDef

      protected com.badlogic.gdx.physics.box2d.BodyDef bodyDef
      the BodyDef to use in createSegment(int, int, Chain)
    • shape

      protected com.badlogic.gdx.physics.box2d.Shape shape
      the Shape to use in createSegment(int, int, Chain)
    • density

      protected float density
      the density to use in Body.createFixture(Shape, float)
    • jointDef

      protected com.badlogic.gdx.physics.box2d.JointDef jointDef
      the JointDef to use in createSegment(int, int, Chain)
  • Constructor Details

    • DefShapeBuilder

      public DefShapeBuilder​(com.badlogic.gdx.physics.box2d.World world, com.badlogic.gdx.physics.box2d.BodyDef bodyDef, com.badlogic.gdx.physics.box2d.Shape shape, float density, com.badlogic.gdx.physics.box2d.JointDef jointDef)
      Parameters:
      world - the world
      bodyDef - the bodyDef
      shape - the Shape
      density - the density
      jointDef - the jointDef
  • Method Details

    • createSegment

      public com.badlogic.gdx.physics.box2d.Body createSegment​(int index, int length, Chain chain)
      creates a segment using bodyDef, shape and density
      Specified by:
      createSegment in interface Chain.Builder
      Parameters:
      index - the index of the segment to create
      length - the desired length of the Chain that is being build
      chain - the Chain this segment will be added to
      Returns:
      the created segment
      See Also:
      Body.createFixture(Shape, float)
    • createConnection

      public Chain.Connection createConnection​(com.badlogic.gdx.physics.box2d.Body seg1, int seg1index, com.badlogic.gdx.physics.box2d.Body seg2, int seg2index)
      Description copied from interface: Chain.Builder
      connects two segments with each other using a Chain.Connection
      Specified by:
      createConnection in interface Chain.Builder
      Parameters:
      seg1 - the first segment
      seg1index - the index of the first segment
      seg2 - the second segment
      seg2index - the index of the second segment
      Returns:
      a new Joint created with jointDef
    • dispose

      public void dispose()
      disposes the shape
      Specified by:
      dispose in interface com.badlogic.gdx.utils.Disposable
    • getWorld

      public com.badlogic.gdx.physics.box2d.World getWorld()
      Returns:
      the world
    • setWorld

      public void setWorld​(com.badlogic.gdx.physics.box2d.World world)
      Parameters:
      world - the world to set
    • getBodyDef

      public com.badlogic.gdx.physics.box2d.BodyDef getBodyDef()
      Returns:
      the bodyDef
    • setBodyDef

      public void setBodyDef​(com.badlogic.gdx.physics.box2d.BodyDef bodyDef)
      Parameters:
      bodyDef - the bodyDef to set
    • getDensity

      public float getDensity()
      Returns:
      the density
    • setDensity

      public void setDensity​(float density)
      Parameters:
      density - the density to set
    • getJointDef

      public com.badlogic.gdx.physics.box2d.JointDef getJointDef()
      Returns:
      the jointDef
    • setJointDef

      public void setJointDef​(com.badlogic.gdx.physics.box2d.JointDef jointDef)
      Parameters:
      jointDef - the jointDef to set
    • getShape

      public com.badlogic.gdx.physics.box2d.Shape getShape()
      Returns:
      the shape