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
-
Field Summary
Fields Modifier and Type Field Description protected com.badlogic.gdx.graphics.g2d.SpritespriteFields inherited from class com.mygdx.game.Components.Component
parent, reqsMet, requirements, type -
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
Modifier and Type Method Description voidcleanUp()Called once after the update loop has finished.com.badlogic.gdx.graphics.g2d.SpritegetSprite()voidhide()booleanisVisible()voidrender()Called once per frame used exclusively for renderingvoidsetTexture(com.badlogic.gdx.graphics.g2d.Sprite s)Asignes a new texture compatible with textures sourced from atlasvoidshow()voidtoggleVisibility()voidupdate()Locates the sprite at the position of the parent's Transform component.Methods inherited from class com.mygdx.game.Components.Component
awake, getParent, getType, setParent, setRequirements, startMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
sprite
protected com.badlogic.gdx.graphics.g2d.Sprite sprite
-
-
Constructor Details
-
Renderable
public Renderable()Called in other constructors, loads no textures by itself. -
Renderable
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
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 Details
-
update
public void update()Locates the sprite at the position of the parent's Transform component. -
render
public void render()Description copied from class:ComponentCalled once per frame used exclusively for rendering -
cleanUp
public void cleanUp()Description copied from class:ComponentCalled once after the update loop has finished. -
getSprite
public com.badlogic.gdx.graphics.g2d.Sprite getSprite() -
setTexture
public void setTexture(com.badlogic.gdx.graphics.g2d.Sprite s)Asignes a new texture compatible with textures sourced from atlas- Parameters:
s- the sprite contain the texture
-
isVisible
public boolean isVisible() -
show
public void show() -
hide
public void hide() -
toggleVisibility
public void toggleVisibility()
-