Package com.mygdx.game.Components
Class Renderable
- java.lang.Object
-
- com.mygdx.game.Components.Component
-
- com.mygdx.game.Components.Renderable
-
public class Renderable extends Component
Add the ability for the object to be shown
-
-
Constructor Summary
Constructors Constructor Description Renderable()
Called in other constructors, loads no textures by itself.Renderable(int texId, RenderLayer layer)
Associates Renderable with the given texture sprite and layer.Renderable(int atlasId, java.lang.String texName, RenderLayer layer)
Associates Renderable with the given sprite from a texture atlas and a layer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanUp()
Called once after the update loop has finished.com.badlogic.gdx.graphics.g2d.Sprite
getSprite()
void
hide()
Changes the visibility to inactiveboolean
isVisible()
void
render()
Checks if the sprite exists and should be visible, then renders itvoid
setTexture(com.badlogic.gdx.graphics.g2d.Sprite s)
Assigns a new texture compatible with textures sourced from atlasvoid
show()
Changes the visibility to activevoid
update()
Locates the sprite at the position of the parent's Transform component.
-
-
-
Constructor Detail
-
Renderable
public Renderable()
Called in other constructors, loads no textures by itself.
-
Renderable
public Renderable(int texId, RenderLayer layer)
Associates Renderable with the given texture sprite and layer.- Parameters:
texId
- the id of the texture the sprite will take onlayer
- the rendering layer
-
Renderable
public Renderable(int atlasId, java.lang.String texName, RenderLayer layer)
Associates Renderable with the given sprite from a texture atlas and a layer.- Parameters:
atlasId
- the id of the texture atlas containing the spritetexName
- the name of the texture the sprite will take onlayer
- the rendering layer
-
-
Method Detail
-
update
public void update()
Locates the sprite at the position of the parent's Transform component.
-
render
public void render()
Checks if the sprite exists and should be visible, then renders it
-
cleanUp
public void cleanUp()
Called once after the update loop has finished.
-
getSprite
public com.badlogic.gdx.graphics.g2d.Sprite getSprite()
- Returns:
- the Sprite for this object
-
setTexture
public void setTexture(com.badlogic.gdx.graphics.g2d.Sprite s)
Assigns a new texture compatible with textures sourced from atlas- Parameters:
s
- the sprite contain the texture
-
isVisible
public boolean isVisible()
- Returns:
- whether the object should currently be visible
-
show
public void show()
Changes the visibility to active
-
hide
public void hide()
Changes the visibility to inactive
-
-