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
,ApplicationContext
,ApplicationProvider
,ComponentsContext
,ComponentsProvider
,EntityContext
,EntityProvider
,SceneContext
,SceneProvider
-
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) Gets a child entity with a given 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) Gets a parent entity with a given tag.boolean
isDescendantOf
(Transform parent) 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, getApplication, getEntity, getName, getScene, hashCode, setActive, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface dev.prozilla.pine.core.ApplicationProvider
getConfig, getInput, getLogger, getModManager, getRenderer, getTimer, getTracker, getWindow
Methods inherited from interface dev.prozilla.pine.core.component.ComponentsProvider
getComponent, getComponents
Methods inherited from interface dev.prozilla.pine.core.entity.EntityContext
isDescendantOf
Methods inherited from interface dev.prozilla.pine.core.entity.EntityProvider
getTransform
Methods inherited from interface dev.prozilla.pine.common.Lifecycle
destroy, init, init, input, input, render, render, start, update, update
Methods inherited from interface dev.prozilla.pine.core.scene.SceneProvider
getCameraData, getWorld
-
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
-
getFirstChild
-
getLastChild
-
isDescendantOf
-
getChildWithTag
Description copied from interface:EntityContext
Gets a child entity with a given tag.- Parameters:
tag
- Tag of the child entity.- Returns:
- The child entity with the given tag, or null if there isn't one.
-
getParentWithTag
Description copied from interface:EntityContext
Gets a parent entity with a given tag.- Parameters:
tag
- Tag of the parent entity.- Returns:
- The parent entity with the given tag, or null if there isn't one.
-
getComponentInParent
-
getComponentInParent
-
getComponentsInChildren
-
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.
-