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 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 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