Package com.mygdx.game.Components
Class Transform
- java.lang.Object
-
- com.mygdx.game.Components.Component
-
- com.mygdx.game.Components.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)
-
-
Field Summary
-
Fields inherited from class com.mygdx.game.Components.Component
parent, reqsMet, requirements, type
-
-
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 componentfloat
vectorToAngle(com.badlogic.gdx.math.Vector2 vector)
Return new angle in radians from input vector.
-
-
-
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 positionrb
- 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
- coordinatey
- coordinaterb_
- 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
- coordinatey
- coordinate
-
setScale
public void setScale(float x, float y)
Sets the scale of the component- Parameters:
x
- the x dimensiony
- 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 interfacecom.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 interfacecom.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 interfacecom.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 interfacecom.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 interfacecom.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
- Parameters:
outVector
- 2D vectorangle
- 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 interfacecom.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
-
-