Module technology.sola.engine
Class TransformComponent
java.lang.Object
technology.sola.engine.core.component.TransformComponent
- All Implemented Interfaces:
technology.sola.ecs.Component
TransformComponent is a
Component
containing translate and scale data for an Entity
.-
Constructor Summary
ConstructorsConstructorDescriptionCreates a transform with position at (0, 0) and scale set to 1.TransformComponent
(float x, float y) Creates a transform with desired position and scale set to 1.TransformComponent
(float x, float y, float scale) Creates a transform with desired position and scale set to the desired value.TransformComponent
(float x, float y, float scaleX, float scaleY) Creates a transform with desired position and scale x and y set to the desired values.TransformComponent
(float x, float y, float scaleX, float scaleY, technology.sola.ecs.Entity parent) Creates a transform that has position based on a parent.TransformComponent
(float x, float y, float scale, technology.sola.ecs.Entity parent) Creates a transform that has position based on a parent.TransformComponent
(float x, float y, technology.sola.ecs.Entity parent) Creates a transform that has position based on a parent.TransformComponent
(technology.sola.ecs.Entity parent) Creates a transform that has position based on a parent. -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterDeserialize
(technology.sola.ecs.World world) @Nullable String
float
float
float
getX()
float
getY()
setParent
(@Nullable technology.sola.ecs.Entity entity) Sets the parent of this TransformComponent.void
setScale
(float scale) Sets the horizontal and vertical scale of the transform to the same value.void
setScale
(float scaleX, float scaleY) Sets the scale of the transform.void
setScaleX
(float scaleX) Sets the horizontal scale.void
setScaleY
(float scaleY) Sets the vertical scale.void
setTranslate
(float x, float y) Sets the translation of the transform.void
setTranslate
(Vector2D translate) Sets the translation of the transform.void
setX
(float x) Sets the new translation x or offset x of parent.void
setY
(float y) Sets the new translation y or offset y of parent.
-
Constructor Details
-
TransformComponent
public TransformComponent()Creates a transform with position at (0, 0) and scale set to 1. -
TransformComponent
public TransformComponent(float x, float y) Creates a transform with desired position and scale set to 1.- Parameters:
x
- the x position coordinatey
- the y position coordinate
-
TransformComponent
public TransformComponent(float x, float y, float scale) Creates a transform with desired position and scale set to the desired value.- Parameters:
x
- the x position coordinatey
- the y position coordinatescale
- the scale of the transform
-
TransformComponent
public TransformComponent(float x, float y, float scaleX, float scaleY) Creates a transform with desired position and scale x and y set to the desired values.- Parameters:
x
- the x position coordinatey
- the y position coordinatescaleX
- the horizontal scalescaleY
- the vertical scale
-
TransformComponent
public TransformComponent(technology.sola.ecs.Entity parent) Creates a transform that has position based on a parent. It has an offset from the parent (0, 0) and scale set to 1 of its parent's scale.- Parameters:
parent
- the parentEntity
(must also have aTransformComponent
)
-
TransformComponent
public TransformComponent(float x, float y, technology.sola.ecs.Entity parent) Creates a transform that has position based on a parent. It has desired offset from the parent and scale set to 1 of its parent's scale.- Parameters:
x
- offset x from parenty
- offset y from parentparent
- the parentEntity
(must also have aTransformComponent
)
-
TransformComponent
public TransformComponent(float x, float y, float scale, technology.sola.ecs.Entity parent) Creates a transform that has position based on a parent. It has desired offset from the parent and desired scale of its parent's scale.- Parameters:
x
- offset x from parenty
- offset y from parentscale
- the scale of the parent's scaleparent
- the parentEntity
(must also have aTransformComponent
)
-
TransformComponent
public TransformComponent(float x, float y, float scaleX, float scaleY, technology.sola.ecs.Entity parent) Creates a transform that has position based on a parent. It has desired offset from the parent and desired scale of its parent's scale.- Parameters:
x
- offset x from parenty
- offset y from parentscaleX
- the horizontal scale of the parent's scalescaleY
- the vertical scale of the parent's scaleparent
- the parentEntity
(must also have aTransformComponent
)
-
-
Method Details
-
afterDeserialize
public void afterDeserialize(technology.sola.ecs.World world) - Specified by:
afterDeserialize
in interfacetechnology.sola.ecs.Component
-
getX
public float getX()- Returns:
- the x coordinate or x offset of parent
-
getY
public float getY()- Returns:
- the y coordinate or y offset of parent
-
getTranslate
- Returns:
- the translation of the transform as a
Vector2D
-
setX
public void setX(float x) Sets the new translation x or offset x of parent.- Parameters:
x
- the new translation x
-
setY
public void setY(float y) Sets the new translation y or offset y of parent.- Parameters:
y
- the new translation y
-
setTranslate
Sets the translation of the transform.- Parameters:
translate
- the new translation
-
setTranslate
public void setTranslate(float x, float y) Sets the translation of the transform.- Parameters:
x
- the new x translationy
- the new y translation
-
getScaleX
public float getScaleX()- Returns:
- the horizontal scale
-
getScaleY
public float getScaleY()- Returns:
- the vertical scale
-
getParentUniqueId
- Returns:
- the parent's unique id or null if no parent
-
setScale
public void setScale(float scaleX, float scaleY) Sets the scale of the transform.- Parameters:
scaleX
- horizontal scalescaleY
- vertical scale
-
setScale
public void setScale(float scale) Sets the horizontal and vertical scale of the transform to the same value.- Parameters:
scale
- the new scale
-
setScaleX
public void setScaleX(float scaleX) Sets the horizontal scale.- Parameters:
scaleX
- the new horizontal scale
-
setScaleY
public void setScaleY(float scaleY) Sets the vertical scale.- Parameters:
scaleY
- hte new vertical scale
-
setParent
Sets the parent of this TransformComponent.- Parameters:
entity
- the parentEntity
or null if no parent- Returns:
- this
-