Class GuiElement

java.lang.Object
rekit.logic.gui.GuiElement
Direct Known Subclasses:
BackgroundElement, LevelGuiElement, MenuItem, Text, TimeDecorator

public abstract class GuiElement extends Object
In contrast to 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 Details

    • visible

      protected boolean visible
      Indicates whether the Element is visible.
    • pos

      protected Vec pos
      The current position.
    • size

      protected Vec size
      The current size.
    • scene

      protected final IScene scene
      The corresponding scene.
  • Constructor Details

    • GuiElement

      protected GuiElement(IScene scene)
      Create by scene.
      Parameters:
      scene - the scene
    • GuiElement

      public GuiElement(IScene scene, Vec size)
      Create by scene and size.
      Parameters:
      scene - the scene
      size - the size
  • Method Details

    • setPos

      public final void setPos(Vec value)
      Set the position.
      Parameters:
      value - the new position
    • getPos

      public final Vec getPos()
      Get the current position.
      Returns:
      the current position
    • getSize

      public final Vec 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

      public IScene 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

      public final Void render(GameGrid f)

      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 - the GameGrid that represents the games field and supplies primitive drawing operations.
      Returns:
      null (for lambda usage)
    • internalRender

      protected abstract void internalRender(GameGrid f)

      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 - the GameGrid that represents the games field and supplies primitive drawing operations.