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.Vector2angleToVector(com.badlogic.gdx.math.Vector2 outVector, float angle)Return new vector combining input vector with input angle in radians.com.badlogic.gdx.math.Vector2getCenter()returns the box2d position of the parent or the transform pos if no rigidbody foundvoidgetLocation()floatgetOrientation()com.badlogic.gdx.math.Vector2getPosition()floatgetRotation()com.badlogic.gdx.math.Vector2getScale()com.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>newLocation()voidsetOrientation(float orientation)voidsetPosition(float x, float y)Set position associated with the Transform component.voidsetPosition(float x, float y, boolean rb_)Set position associated with the Transform component.voidsetPosition(com.badlogic.gdx.math.Vector2 pos)Set position associated with the Transform component.voidsetPosition(com.badlogic.gdx.math.Vector2 pos, boolean rb)Set position associated with the Transform component.voidsetRotation(float rot)voidsetScale(float x, float y)voidsetScale(com.badlogic.gdx.math.Vector2 pos)floatvectorToAngle(com.badlogic.gdx.math.Vector2 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(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:
getPositionin interfacecom.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:
getOrientationin interfacecom.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
-
setOrientation
public void setOrientation(float orientation)
- Specified by:
setOrientationin interfacecom.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
-
vectorToAngle
public float vectorToAngle(com.badlogic.gdx.math.Vector2 vector)
- Specified by:
vectorToAnglein interfacecom.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:
angleToVectorin 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:
newLocationin interfacecom.badlogic.gdx.ai.utils.Location<com.badlogic.gdx.math.Vector2>
-
getScale
public com.badlogic.gdx.math.Vector2 getScale()
-
getRotation
public float getRotation()
- Returns:
- radians
-
-