Class RigidBody


  • public class RigidBody
    extends Component
    Defines parameters related to collisions of sprites.
    • Constructor Detail

      • RigidBody

        public RigidBody()
      • RigidBody

        public RigidBody​(PhysicsBodyType type,
                         Renderable r,
                         Transform t)
        Calls constructor with is trigger false
        Parameters:
        type - defines how it interacts with other objects
        r - used for creating the fixture (aka the collider)
        t - used for positioning and scaling the collider
      • RigidBody

        public RigidBody​(PhysicsBodyType type,
                         Renderable r,
                         Transform t,
                         boolean isTrigger)
        Can create body that is trigger or callable
        Parameters:
        type - defines how it interacts with other objects
        r - used for creating the fixture (aka the collider)
        t - used for positioning and scaling the collider
        isTrigger - false allows for collision true doesn't
    • Method Detail

      • addTrigger

        public void addTrigger​(float radius,
                               java.lang.Object data)
        Adds a new circular fixture to the body as a trigger
      • setCallback

        public void setCallback​(CollisionCallBack data)
        Is used during collision phase to add more functionality
        Parameters:
        data - class that inherits from CollisionCallBack
      • setVelocity

        public void setVelocity​(com.badlogic.gdx.math.Vector2 vel)
      • setVelocity

        public void setVelocity​(float x,
                                float y)
      • setPosition

        public void setPosition​(com.badlogic.gdx.math.Vector2 position)
        Sets the center pos of the object
      • setPosition

        public void setPosition​(com.badlogic.gdx.math.Vector2 position,
                                boolean offset)
        Sets the bottom left position of the object
        Parameters:
        offset - should probably offset
      • getBody

        public com.badlogic.gdx.physics.box2d.Body getBody()
      • update

        public void update()
        Called every frame translates the transform to match with the box2d body's position factoring offset
        Overrides:
        update in class Component
      • getVelocity

        public com.badlogic.gdx.math.Vector2 getVelocity()
      • getAngularVelocity

        public float getAngularVelocity()
      • applyForce

        public void applyForce​(com.badlogic.gdx.math.Vector2 force)