Package com.xebisco.yield
Class ComponentBehavior
java.lang.Object
com.xebisco.yield.AbstractBehavior
com.xebisco.yield.ComponentBehavior
- All Implemented Interfaces:
Behavior,Renderable,Closeable,AutoCloseable
- Direct Known Subclasses:
AbstractRenderable,AnimationPlayer,AudioPlayer,Collider2D,Joint2D,PhysicsBody
Abstract class representing a behavior that can be attached to an
Entity2D.
It provides methods for updating, rendering, and accessing entity-related information.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the application this behavior belongs to.voidclose()Called when the behavior is closed.<T extends ComponentBehavior>
TReturns a component of the specified type attached to the entity this behavior is attached to.<T extends ComponentBehavior>
TReturns a component of the specified type and index attached to the entity this behavior is attached to.entity()Returns the entity this behavior is attached to.voidonCreate()Called when the behavior is created.voidonLateUpdate(ContextTime time) Called after allonUpdate(ContextTime)calls.voidonStart()Called when the entity starts.voidonUpdate(ContextTime time) Called every frame.voidRenders the behavior.intReturns the render index of the entity this behavior is attached to.Sets the entity this behavior is attached to.setRenderIndex(int index) Sets the render index of the entity this behavior is attached to.final AbstractTextureReturns a texture loaded on demand from the specified path with a default linear filter.final AbstractTexturetexture(String path, TextureFilter filter) Returns a texture loaded on demand from the specified path and filter.Returns the transform of the entity this behavior is attached to.Methods inherited from class com.xebisco.yield.AbstractBehavior
frames, tick
-
Constructor Details
-
ComponentBehavior
public ComponentBehavior()
-
-
Method Details
-
onCreate
public void onCreate()Called when the behavior is created. -
onLateUpdate
Called after allonUpdate(ContextTime)calls.- Parameters:
time- The context time.
-
onStart
public void onStart()Called when the entity starts. -
onUpdate
Called every frame. -
close
Called when the behavior is closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- If an I/O error occurs.
-
render
Renders the behavior.- Specified by:
renderin interfaceRenderable- Parameters:
renderer- The renderer.
-
entity
Returns the entity this behavior is attached to.- Returns:
- The entity.
-
application
Returns the application this behavior belongs to.- Returns:
- The application.
-
setEntity
Sets the entity this behavior is attached to.- Parameters:
entity- The entity.- Returns:
- This behavior.
-
transform
Returns the transform of the entity this behavior is attached to.- Returns:
- The transform.
-
renderIndex
public int renderIndex()Returns the render index of the entity this behavior is attached to.- Returns:
- The render index.
-
setRenderIndex
Sets the render index of the entity this behavior is attached to.- Parameters:
index- The render index.- Returns:
- This behavior.
-
component
Returns a component of the specified type attached to the entity this behavior is attached to.- Parameters:
componentType- The type of the component.- Returns:
- The component.
-
component
Returns a component of the specified type and index attached to the entity this behavior is attached to.- Parameters:
componentType- The type of the component.index- The index of the component.- Returns:
- The component.
-
texture
Returns a texture loaded on demand from the specified path and filter.- Parameters:
path- The path of the texture.filter- The texture filter.- Returns:
- The texture.
-
texture
Returns a texture loaded on demand from the specified path with a default linear filter.- Parameters:
path- The path of the texture.- Returns:
- The texture.
-