Class Transform

  • All Implemented Interfaces:
    com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>

    public class Transform
    extends Component
    implements com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
    Position, Scale, Rotation (in radians clockwise)
    • Constructor Summary

      Constructors 
      Constructor Description
      Transform()
      position = (0, 0) scale = (0, 0) rotation = 0 rot not used but easy to add functionality for
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.badlogic.gdx.math.Vector2 angleToVector​(com.badlogic.gdx.math.Vector2 outVector, float angle)
      Return new vector combining input vector with input angle in radians.
      com.badlogic.gdx.math.Vector2 getCenter()
      returns the box2d position of the parent or the transform pos if no rigidbody found
      void getLocation()  
      float getOrientation()  
      com.badlogic.gdx.math.Vector2 getPosition()  
      float getRotation()  
      com.badlogic.gdx.math.Vector2 getScale()  
      com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2> newLocation()  
      void setOrientation​(float orientation)  
      void setPosition​(float x, float y)
      Set position associated with the Transform component.
      void setPosition​(float x, float y, boolean rb_)
      Set position associated with the Transform component.
      void setPosition​(com.badlogic.gdx.math.Vector2 pos)
      Set position associated with the Transform component.
      void setPosition​(com.badlogic.gdx.math.Vector2 pos, boolean rb)
      Set position associated with the Transform component.
      void setRotation​(float rot)  
      void setScale​(float x, float y)  
      void setScale​(com.badlogic.gdx.math.Vector2 pos)  
      float vectorToAngle​(com.badlogic.gdx.math.Vector2 vector)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Transform

        public Transform()
        position = (0, 0) scale = (0, 0) rotation = 0 rot not used but easy to add functionality for
    • Method Detail

      • setPosition

        public void setPosition​(com.badlogic.gdx.math.Vector2 pos,
                                boolean rb)
        Set position associated with the Transform component.
        Parameters:
        pos - 2D vector specifying the position
        rb - true to pass on the position to the parent's RigidBody
      • setPosition

        public void setPosition​(float x,
                                float y,
                                boolean rb_)
        Set position associated with the Transform component.
        Parameters:
        x - coordinate
        y - coordinate
        rb_ - true to pass on the position to the parent's RigidBody
      • setPosition

        public void setPosition​(com.badlogic.gdx.math.Vector2 pos)
        Set position associated with the Transform component.
        Parameters:
        pos - 2D vector specifying the position
      • setPosition

        public void setPosition​(float x,
                                float y)
        Set position associated with the Transform component.
        Parameters:
        x - coordinate
        y - coordinate
      • setScale

        public void setScale​(com.badlogic.gdx.math.Vector2 pos)
      • setScale

        public void setScale​(float x,
                             float y)
      • setRotation

        public void setRotation​(float rot)
        Parameters:
        rot - in Radians
      • getPosition

        public com.badlogic.gdx.math.Vector2 getPosition()
        Specified by:
        getPosition in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
      • getCenter

        public com.badlogic.gdx.math.Vector2 getCenter()
        returns the box2d position of the parent or the transform pos if no rigidbody found
        Returns:
        the center of the Entity or bottom left
      • getLocation

        public void getLocation()
      • getOrientation

        public float getOrientation()
        Specified by:
        getOrientation in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
      • setOrientation

        public void setOrientation​(float orientation)
        Specified by:
        setOrientation in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
      • vectorToAngle

        public float vectorToAngle​(com.badlogic.gdx.math.Vector2 vector)
        Specified by:
        vectorToAngle in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
      • angleToVector

        public com.badlogic.gdx.math.Vector2 angleToVector​(com.badlogic.gdx.math.Vector2 outVector,
                                                           float angle)
        Return new vector combining input vector with input angle in radians.
        Specified by:
        angleToVector in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
        Parameters:
        outVector - 2D vector
        angle - in radians
        Returns:
        the angle as a vector
      • newLocation

        public com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2> newLocation()
        Specified by:
        newLocation in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
      • getScale

        public com.badlogic.gdx.math.Vector2 getScale()
      • getRotation

        public float getRotation()
        Returns:
        radians