Package com.csse3200.game.rendering
Class DynamicTextureRenderComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.rendering.DynamicTextureRenderComponent
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable,com.badlogic.gdx.utils.Json.Serializable,Renderable,Comparable<Renderable>
Render a static texture.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionDynamicTextureRenderComponent(com.badlogic.gdx.graphics.Texture texture) DynamicTextureRenderComponent(String texturePath) -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddraw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable.intgetLayer()Layer to be rendered in.voidScale the entity to a width of 1 and a height matching the texture's ratiovoidsetLayer(int layer) voidsetTexture(String texturePath) Methods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, create, dispose, getZIndex, renderMethods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, read, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update, write
-
Constructor Details
-
DynamicTextureRenderComponent
- Parameters:
texturePath- Internal path of static texture to render. Will be scaled to the entity's scale.
-
DynamicTextureRenderComponent
public DynamicTextureRenderComponent(com.badlogic.gdx.graphics.Texture texture) - Parameters:
texture- Static texture to render. Will be scaled to the entity's scale.
-
-
Method Details
-
setTexture
-
scaleEntity
public void scaleEntity()Scale the entity to a width of 1 and a height matching the texture's ratio -
draw
protected void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Description copied from class:RenderComponentDraw the renderable. Should be called only by the renderer, not manually.- Specified by:
drawin classRenderComponent- Parameters:
batch- Batch to render to.
-
setLayer
public void setLayer(int layer) -
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- Overrides:
getLayerin classRenderComponent- Returns:
- layer
-