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.
      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)
      Sets the scale of the component
      float vectorToAngle​(com.badlogic.gdx.math.Vector2 vector)
      Return new angle in radians from input 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​(float x,
                             float y)
        Sets the scale of the component
        Parameters:
        x - the x dimension
        y - the y dimension
      • 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>
        Returns:
        the position of the component on the grid
      • getOrientation

        public float getOrientation()
        Specified by:
        getOrientation in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
        Returns:
        the orientation of the component `unused`
      • setOrientation

        public void setOrientation​(float orientation)
        Specified by:
        setOrientation in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
        Parameters:
        orientation - the float value to set the orientation of the component to `unused`
      • vectorToAngle

        public float vectorToAngle​(com.badlogic.gdx.math.Vector2 vector)
        Return new angle in radians from input vector.
        Specified by:
        vectorToAngle in interface com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
        Parameters:
        vector - 2D vector
        Returns:
        the vector as an angle
      • 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>
        Returns:
        a Transform object at a new location
      • getScale

        public com.badlogic.gdx.math.Vector2 getScale()
        Returns:
        the scale of this object
      • getRotation

        public float getRotation()
        Returns:
        the angle of this object in radians