Package com.csse3200.game.rendering
Class TextureRenderComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.rendering.RenderComponent
com.csse3200.game.rendering.TextureRenderComponent
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable,Renderable,Comparable<Renderable>
- Direct Known Subclasses:
BackgroundRenderComponent
Render a static texture.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionTextureRenderComponent(com.badlogic.gdx.graphics.Texture texture) TextureRenderComponent(String texturePath) -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddraw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable.floatGets the height of the textureintgetLayer()Layer to be rendered in.com.badlogic.gdx.graphics.TexturefloatgetWidth()Gets the width of the texturevoidScale the entity to a width of 1 and a height matching the texture's ratiovoidsetStage(com.badlogic.gdx.scenes.scene2d.Stage mock) voidsetTexture(String texturePath) Updates the texture with a new one.Methods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, create, dispose, getZIndex, renderMethods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Constructor Details
-
TextureRenderComponent
- Parameters:
texturePath- Internal path of static texture to render. Will be scaled to the entity's scale.
-
TextureRenderComponent
public TextureRenderComponent(com.badlogic.gdx.graphics.Texture texture) - Parameters:
texture- Static texture to render. Will be scaled to the entity's scale.
-
-
Method Details
-
getTexturePath
-
setTexture
Updates the texture with a new one.- Parameters:
texturePath- Internal path of the new texture to render.
-
scaleEntity
public void scaleEntity()Scale the entity to a width of 1 and a height matching the texture's ratio -
getWidth
public float getWidth()Gets the width of the texture- Returns:
- the width of the texture
-
getTexture
public com.badlogic.gdx.graphics.Texture getTexture() -
getHeight
public float getHeight()Gets the height of the texture- Returns:
- the height of the texture
-
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.
-
setStage
public void setStage(com.badlogic.gdx.scenes.scene2d.Stage mock) -
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
-