Class TransformComponent

java.lang.Object
technology.sola.engine.core.component.TransformComponent
All Implemented Interfaces:
technology.sola.ecs.Component

@NullMarked public class TransformComponent extends Object implements technology.sola.ecs.Component
TransformComponent is a Component containing translate and scale data for an Entity.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates 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 Type
    Method
    Description
    void
    afterDeserialize(technology.sola.ecs.World world)
     
    @Nullable String
     
    float
     
    float
     
     
    float
     
    float
     
    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
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 coordinate
      y - 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 coordinate
      y - the y position coordinate
      scale - 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 coordinate
      y - the y position coordinate
      scaleX - the horizontal scale
      scaleY - 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 parent Entity (must also have a TransformComponent)
    • 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 parent
      y - offset y from parent
      parent - the parent Entity (must also have a TransformComponent)
    • 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 parent
      y - offset y from parent
      scale - the scale of the parent's scale
      parent - the parent Entity (must also have a TransformComponent)
    • 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 parent
      y - offset y from parent
      scaleX - the horizontal scale of the parent's scale
      scaleY - the vertical scale of the parent's scale
      parent - the parent Entity (must also have a TransformComponent)
  • Method Details

    • afterDeserialize

      public void afterDeserialize(technology.sola.ecs.World world)
      Specified by:
      afterDeserialize in interface technology.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

      public Vector2D 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

      public void setTranslate(Vector2D translate)
      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 translation
      y - the new y translation
    • getScaleX

      public float getScaleX()
      Returns:
      the horizontal scale
    • getScaleY

      public float getScaleY()
      Returns:
      the vertical scale
    • getParentUniqueId

      public @Nullable String 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 scale
      scaleY - 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

      public TransformComponent setParent(@Nullable technology.sola.ecs.Entity entity)
      Sets the parent of this TransformComponent.
      Parameters:
      entity - the parent Entity or null if no parent
      Returns:
      this