Package com.deco2800.game.rendering
Class TextureRenderComponent
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.rendering.RenderComponent
com.deco2800.game.rendering.TextureRenderComponent
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable,Renderable,Comparable<Renderable>
Render a static texture.
-
Field Summary
Fields -
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.voiddrawTextureBox(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draws a square around the area enclosed by the texture - for debuggingvoiddrawTextureBox(List<com.badlogic.gdx.math.Vector2> positions, List<com.badlogic.gdx.math.Vector2> linePos, com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Debug function which draws a box around an entity with a TextureRenderComponentcom.badlogic.gdx.graphics.TexturevoidScale the entity to a width of 1 and a height matching the texture's ratiovoidsetTexture(com.badlogic.gdx.graphics.Texture texture) voidvoidsetTexturePath(String path) Methods inherited from class com.deco2800.game.rendering.RenderComponent
compareTo, create, dispose, getLayer, getZIndex, renderMethods inherited from class com.deco2800.game.components.Component
earlyUpdate, getEntity, isAnimationRenderComponent, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
Field Details
-
texturePath
-
-
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
-
scaleEntity
public void scaleEntity()Scale the entity to a width of 1 and a height matching the texture's ratio -
drawTextureBox
public void drawTextureBox(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draws a square around the area enclosed by the texture - for debugging- Parameters:
batch- SpriteBatch of game
-
drawTextureBox
public void drawTextureBox(List<com.badlogic.gdx.math.Vector2> positions, List<com.badlogic.gdx.math.Vector2> linePos, com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Debug function which draws a box around an entity with a TextureRenderComponent- Parameters:
positions- positions to draw a box aroundlinePos- list of points to draw lines betweenbatch- the SpriteBatch of the game
-
setTexture
public void setTexture(com.badlogic.gdx.graphics.Texture texture) -
setTexturePath
-
setTextureOG
public void setTextureOG() -
getTextureOG
public com.badlogic.gdx.graphics.Texture getTextureOG() -
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.
-