Package rekit.logic.gui
Class GuiElement
java.lang.Object
rekit.logic.gui.GuiElement
- Direct Known Subclasses:
BackgroundElement,LevelGuiElement,MenuItem,Text,TimeDecorator
In contrast to
So everything which will not interact in the game and has to be shown is a GuiElement
GameElements this class represents stuff
like score banners, texts etc.So everything which will not interact in the game and has to be shown is a GuiElement
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedGuiElement(IScene scene) Create by scene.GuiElement(IScene scene, Vec size) Create by scene and size. -
Method Summary
Modifier and TypeMethodDescriptionfinal VecgetPos()Get the current position.getScene()Get the corresponding scene.final VecgetSize()Get the current size.protected abstract voidTemplate method that will be called periodically after being added to aIScene.booleanGet the current visibility.voidTemplate method that will be called periodically after being added to aIScene.final VoidMethod that will be called periodically after being added to aIScene.final voidSet the position.voidsetVisible(boolean visible) Set the visibility.
-
Field Details
-
visible
protected boolean visibleIndicates whether the Element is visible. -
pos
The current position. -
size
The current size. -
scene
The corresponding scene.
-
-
Constructor Details
-
GuiElement
Create by scene.- Parameters:
scene- the scene
-
GuiElement
Create by scene and size.- Parameters:
scene- the scenesize- the size
-
-
Method Details
-
setPos
Set the position.- Parameters:
value- the new position
-
getPos
Get the current position.- Returns:
- the current position
-
getSize
Get the current size.- Returns:
- the current size
-
isVisible
public boolean isVisible()Get the current visibility.- Returns:
- the current visibility
-
setVisible
public void setVisible(boolean visible) Set the visibility. An invisible Element will not be rendered.- Parameters:
visible- the new visibility
-
getScene
Get the corresponding scene.- Returns:
- the scene
-
logicLoop
public void logicLoop()Template method that will be called periodically after being added to a
IScene.Should be overwritten in sub classes for implementing custom logic, physics emulation, time-based actions, ...
-
render
Method that will be called periodically after being added to a
IScene.Its only task is to call the template method internalRender(Field f) if the
GuiElementis supposed to be rendered.- Parameters:
f- theGameGridthat represents the games field and supplies primitive drawing operations.- Returns:
null(for lambda usage)
-
internalRender
Template method that will be called periodically after being added to a
IScene. Must be as performant as possible to keep the FPS low, since it will be called in every render-loop.Should be overwritten in sub classes for custom visualization using the
GameGrid.- Parameters:
f- theGameGridthat represents the games field and supplies primitive drawing operations.
-