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
ConstructorsModifierConstructorDescriptionprotected
GuiElement
(IScene scene) Create by scene.GuiElement
(IScene scene, Vec size) Create by scene and size. -
Method Summary
Modifier and TypeMethodDescriptionfinal Vec
getPos()
Get the current position.getScene()
Get the corresponding scene.final Vec
getSize()
Get the current size.protected abstract void
Template method that will be called periodically after being added to aIScene
.boolean
Get the current visibility.void
Template method that will be called periodically after being added to aIScene
.final Void
Method that will be called periodically after being added to aIScene
.final void
Set the position.void
setVisible
(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
GuiElement
is supposed to be rendered.- Parameters:
f
- theGameGrid
that 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
- theGameGrid
that represents the games field and supplies primitive drawing operations.
-