Class BackgroundElement

java.lang.Object
rekit.logic.gameelements.GameElement
rekit.logic.gui.parallax.BackgroundElement
All Implemented Interfaces:
Collidable
Direct Known Subclasses:
HeapElement

public abstract class BackgroundElement extends GameElement
This is the parent class which all background elements shall extend.
  • Field Details

    • parent

      protected ParallaxLayer parent
      The parent parallax.
    • backgroundZ

      protected int backgroundZ
      The z-pos of this element.
  • Constructor Details

    • BackgroundElement

      public BackgroundElement(ParallaxLayer parent, Vec pos)
      Create a BG-Element by parent and pos.
      Parameters:
      parent - the parent
      pos - the positon
  • Method Details

    • getZHint

      public final Integer getZHint()
      Description copied from class: GameElement
      Get a hint (for Team.Range.normalize(int) for positioning this GameElement via GameElement.getZ().
      Overrides:
      getZHint in class GameElement
      Returns:
      null if no hint, otherwise the expected position
    • addDamage

      public void addDamage(int damage)
      Description copied from interface: Collidable
      Optional reaction to a collision. Removes lifes of the GameElement.
      Parameters:
      damage - the amount of lifes to remove
    • getLives

      public int getLives()
      Description copied from interface: Collidable
      Getter for the current lifes of the GameElement.
      Returns:
      the amount of lifes of the GameElement
    • collidedWithSolid

      public void collidedWithSolid(Frame collision, Direction dir)
      Description copied from interface: Collidable
      Optional reaction to a collision that can be invoked in other GameElements reactToCollision(). Notification that this GameElement has collided with another GameElement with the CollisionFrame collision from a given direction dir. Define optional reactions that the GameElement performs on itself upon collision.
      Parameters:
      collision - the Frame of the GameElement that was collided on
      dir - the direction of this GameElement where the collision took place