Class RigidBody


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

      • RigidBody

        public RigidBody()
        Sets up the base values of the RigidBody component
      • 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
      • getPosition

        public com.badlogic.gdx.math.Vector2 getPosition()
        Gets the current player position. // Change for Assessment 2 //
        Returns:
        player position.
      • getBody

        public com.badlogic.gdx.physics.box2d.Body getBody()
        Returns:
        the Body of this object
      • 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()
        Returns:
        the Linear Velocity of this object
      • getAngularVelocity

        public float getAngularVelocity()
        Returns:
        the Angular Velocity of this object
      • applyForce

        public void applyForce​(com.badlogic.gdx.math.Vector2 force)
        Parameters:
        force - the force to apply to the center of the object