Package com.xebisco.yield
Class Entity2D
java.lang.Object
com.xebisco.yield.AbstractBehavior
com.xebisco.yield.Entity2DContainer
com.xebisco.yield.Entity2D
- All Implemented Interfaces:
Behavior,Renderable,Closeable,AutoCloseable
Represents a 2D entity within a game or application.
This class extends
Entity2DContainer and provides functionality for managing components, updating, rendering,
and transforming the entity within its hierarchy.-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()<T extends ComponentBehavior>
TGets the first component of the specified type.<T extends ComponentBehavior>
TGets the component of the specified type at the specified renderIndex.Gets the array of components that this entity manages.booleancontainsTag(String tag) Checks if a given tag is present in the array of tags.Calculates the transformations applied to this entity by its parent and itself.voidonUpdate(ContextTime time) This method is called when the behavior needs to be updated with the current time.parent()Gets the parent entity of this entity, or null if it has no parent.voidRenders the object using the providedRenderer.intGets the renderIndex of this entity.setRenderIndex(int renderIndex) Sets the renderIndex of this entity.setVisible(boolean visible) Sets the visibility of this entity.String[]tags()Gets the array of tags that describe this entity.Gets the transformations applied to this entity.booleanvisible()Gets the visibility of this entity.Methods inherited from class com.xebisco.yield.Entity2DContainer
application, entities, instantiate, instantiate, onStart, remove, setEntities, toAddEntities, toRemoveEntitiesMethods inherited from class com.xebisco.yield.AbstractBehavior
frames, tick
-
Method Details
-
onUpdate
Description copied from interface:BehaviorThis method is called when the behavior needs to be updated with the current time. It is typically used to perform any necessary calculations or updates based on the current time.- Specified by:
onUpdatein interfaceBehavior- Overrides:
onUpdatein classEntity2DContainer- Parameters:
time- The current time context.
-
render
Description copied from interface:RenderableRenders the object using the providedRenderer.- Specified by:
renderin interfaceRenderable- Overrides:
renderin classEntity2DContainer- Parameters:
renderer- The renderer to use for rendering the object.
-
hierarchyTransform
Calculates the transformations applied to this entity by its parent and itself.- Returns:
- The transformations applied to this entity.
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classEntity2DContainer- Throws:
IOException
-
containsTag
Checks if a given tag is present in the array of tags.- Parameters:
tag- The tag to check for.- Returns:
- True if the tag is present in the array of tags, false otherwise.
-
component
Gets the component of the specified type at the specified renderIndex.- Parameters:
componentType- The type of component to retrieve.index- The renderIndex of the component to retrieve.- Returns:
- The component of the specified type at the specified renderIndex, or null if no such component exists.
-
component
Gets the first component of the specified type.- Type Parameters:
T- The type of component to retrieve.- Parameters:
componentType- The type of component to retrieve.- Returns:
- The first component of the specified type, or null if no such component exists.
-
transform
Gets the transformations applied to this entity.- Returns:
- The transformations applied to this entity.
-
components
Gets the array of components that this entity manages.- Returns:
- The array of components that this entity manages.
-
parent
Gets the parent entity of this entity, or null if it has no parent.- Returns:
- The parent entity of this entity, or null if it has no parent.
-
renderIndex
public int renderIndex()Gets the renderIndex of this entity.- Returns:
- The renderIndex of this entity.
-
setRenderIndex
Sets the renderIndex of this entity.- Parameters:
renderIndex- The new renderIndex for this entity.- Returns:
- This entity, for method chaining.
-
tags
Gets the array of tags that describe this entity.- Returns:
- The array of tags that describe this entity.
-
visible
public boolean visible()Gets the visibility of this entity.- Returns:
- The visibility of this entity.
-
setVisible
Sets the visibility of this entity.- Parameters:
visible- True to make this entity visible, false to hide it.- Returns:
- This entity, for method chaining.
-