Class Transform

java.lang.Object
dev.prozilla.pine.core.component.Component
dev.prozilla.pine.core.component.Transform
All Implemented Interfaces:
Lifecycle, Printable, ComponentFinder, EntityFinder

public class Transform extends Component
  • Field Details

    • position

      public Vector2f position
      Local position
    • rotation

      public float rotation
      Rotation in degrees
    • velocity

      public Vector2f velocity
      The velocity vector is added to the position each frame.
    • children

      public final List<Transform> children
      Children of the entity
    • parent

      public Transform parent
      Parent of the entity
  • Constructor Details

    • Transform

      public Transform()
    • Transform

      public Transform(float x, float y)
    • Transform

      public Transform(float x, float y, float rotation)
  • Method Details

    • getChildWithTag

      public Entity getChildWithTag(String tag)
      Specified by:
      getChildWithTag in interface EntityFinder
      Overrides:
      getChildWithTag in class Component
    • getParentWithTag

      public Entity getParentWithTag(String tag)
      Specified by:
      getParentWithTag in interface EntityFinder
      Overrides:
      getParentWithTag in class Component
    • getComponentInParent

      public <ComponentType extends Component> ComponentType getComponentInParent(Class<ComponentType> componentClass)
      Specified by:
      getComponentInParent in interface ComponentFinder
      Overrides:
      getComponentInParent in class Component
    • getComponentInParent

      public <ComponentType extends Component> ComponentType getComponentInParent(Class<ComponentType> componentClass, boolean includeAncestors)
      Specified by:
      getComponentInParent in interface ComponentFinder
      Overrides:
      getComponentInParent in class Component
    • getComponentsInChildren

      public <ComponentType extends Component> List<ComponentType> getComponentsInChildren(Class<ComponentType> componentClass)
      Specified by:
      getComponentsInChildren in interface ComponentFinder
      Overrides:
      getComponentsInChildren in class Component
    • getGlobalX

      public float getGlobalX()
    • getGlobalY

      public float getGlobalY()
    • setParent

      public void setParent(Transform parent)
    • getChildCount

      public int getChildCount()
    • translate

      public void translate(Vector2f delta)
    • translate

      public void translate(float deltaX, float deltaY)
    • setPosition

      public void setPosition(float x, float y)
    • setVelocity

      public void setVelocity(float x, float y)
    • setRenderChildrenBelow

      public void setRenderChildrenBelow(boolean renderChildrenBelow)
    • calculateDepth

      public int calculateDepth(int depth)
      Calculates the z-indices of this transform and its children based on a depth value.
      Parameters:
      depth - Depth value before calculation
      Returns:
      Depth value after calculation
    • getDepthIndex

      public int getDepthIndex()
    • getDepth

      public float getDepth()
      Returns:
      Depth value between 0f and 1f based on the depth index.