Package com.csse3200.game.rendering
Class RenderComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable,Renderable,Comparable<Renderable>
- Direct Known Subclasses:
AnimationRenderComponent,TerrainComponent,TextureRenderComponent,UIComponent
public abstract class RenderComponent
extends Component
implements Renderable, com.badlogic.gdx.utils.Disposable
A generic component for rendering an entity. Registers itself with the render service in order to
be rendered each frame. Child classes can implement different kinds of rendering behaviour.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidcreate()Called when the entity is created and registered.voiddispose()Called when the component is disposed.protected abstract voiddraw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable.intgetLayer()Layer to be rendered in.floatZ index controls rendering order within a layer.voidrender(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Render the renderable.Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
RenderComponent
public RenderComponent()
-
-
Method Details
-
create
public void create()Description copied from class:ComponentCalled when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished. -
dispose
public void dispose()Description copied from class:ComponentCalled when the component is disposed. Dispose of any internal resources here. -
render
public void render(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Description copied from interface:RenderableRender the renderable. Should be called only by the renderer, not manually.- Specified by:
renderin interfaceRenderable- Parameters:
batch- Batch to render to.
-
compareTo
- Specified by:
compareToin interfaceComparable<Renderable>
-
getLayer
public int getLayer()Description copied from interface:RenderableLayer to be rendered in. Higher layers will be rendered on top of lower layers.- Specified by:
getLayerin interfaceRenderable- Returns:
- layer
-
getZIndex
public float getZIndex()Description copied from interface:RenderableZ index controls rendering order within a layer. Higher Z index is drawn on top.- Specified by:
getZIndexin interfaceRenderable- Returns:
- Z index
-
draw
protected abstract void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable. Should be called only by the renderer, not manually.- Parameters:
batch- Batch to render to.
-