Package dev.prozilla.pine.core.component
Class Transform
java.lang.Object
dev.prozilla.pine.core.component.Component
dev.prozilla.pine.core.component.Transform
- All Implemented Interfaces:
Lifecycle
,Printable
,ComponentFinder
,EntityFinder
-
Field Summary
FieldsModifier and TypeFieldDescriptionChildren of the entityParent of the entityLocal positionfloat
Rotation in degreesThe velocity vector is added to the position each frame. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
calculateDepth
(int depth) Calculates the z-indices of this transform and its children based on a depth value.int
getChildWithTag
(String tag) <ComponentType extends Component>
ComponentTypegetComponentInParent
(Class<ComponentType> componentClass) <ComponentType extends Component>
ComponentTypegetComponentInParent
(Class<ComponentType> componentClass, boolean includeAncestors) getComponentsInChildren
(Class<ComponentType> componentClass) float
getDepth()
int
float
float
getParentWithTag
(String tag) void
void
setPosition
(float x, float y) void
setRenderChildrenBelow
(boolean renderChildrenBelow) void
setVelocity
(float x, float y) void
translate
(float deltaX, float deltaY) void
Methods inherited from class dev.prozilla.pine.core.component.Component
equals, getCamera, getComponent, getComponents, getEntity, getInput, getLogger, getName, getRenderer, getTimer, getTracker, getTransform, getWindow, getWorld, hashCode, setActive, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Field Details
-
position
Local position -
rotation
public float rotationRotation in degrees -
velocity
The velocity vector is added to the position each frame. -
children
Children of the entity -
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
- Specified by:
getChildWithTag
in interfaceEntityFinder
- Overrides:
getChildWithTag
in classComponent
-
getParentWithTag
- Specified by:
getParentWithTag
in interfaceEntityFinder
- Overrides:
getParentWithTag
in classComponent
-
getComponentInParent
public <ComponentType extends Component> ComponentType getComponentInParent(Class<ComponentType> componentClass) - Specified by:
getComponentInParent
in interfaceComponentFinder
- Overrides:
getComponentInParent
in classComponent
-
getComponentInParent
public <ComponentType extends Component> ComponentType getComponentInParent(Class<ComponentType> componentClass, boolean includeAncestors) - Specified by:
getComponentInParent
in interfaceComponentFinder
- Overrides:
getComponentInParent
in classComponent
-
getComponentsInChildren
public <ComponentType extends Component> List<ComponentType> getComponentsInChildren(Class<ComponentType> componentClass) - Specified by:
getComponentsInChildren
in interfaceComponentFinder
- Overrides:
getComponentsInChildren
in classComponent
-
getGlobalX
public float getGlobalX() -
getGlobalY
public float getGlobalY() -
setParent
-
getChildCount
public int getChildCount() -
translate
-
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
and1f
based on the depth index.
-