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>
Render a static texture.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionTextureRenderComponent
(com.badlogic.gdx.graphics.Texture texture) TextureRenderComponent
(String texturePath) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
draw
(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable.double
com.badlogic.gdx.graphics.Texture
Returns the texture image pathvoid
Scale the entity to a width of 1 and a height matching the texture's ratiovoid
setOrigin
(float x, float y) void
setRotation
(float rotation) Sets rotation of the texturevoid
setTexture
(String texture) Methods inherited from class com.csse3200.game.rendering.RenderComponent
compareTo, create, dispose, getLayer, getZIndex, render, setLayer
Methods 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
-
setTexture
-
getTexture
public com.badlogic.gdx.graphics.Texture getTexture()Returns the texture image path- Returns:
- the image path
-
setRotation
public void setRotation(float rotation) Sets rotation of the texture- Parameters:
rotation
- What to rotate by (0-360 degrees)
-
getRotation
public double getRotation()- Returns:
- Rotation degree of texture
-
setOrigin
public void setOrigin(float x, float y) -
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:RenderComponent
Draw the renderable. Should be called only by the renderer, not manually.- Specified by:
draw
in classRenderComponent
- Parameters:
batch
- Batch to render to.
-