Package playground

Class LevelMovingHitObjects


public class LevelMovingHitObjects extends SpaceInvadersLevel
Level that creates two RectObjects moving around and if ego is hit by them game is directly lost (lives = 0).
  • Constructor Details

    • LevelMovingHitObjects

      public LevelMovingHitObjects()
  • Method Details

    • prepareLevel

      public void prepareLevel(String id)
      Description copied from class: SpaceInvadersLevel
      initially sets up the level. Not called by user interaction, but called every time a layer is restarted from scratch. So make sure that this is possible. Here, resources are loaded only once even if method is called several times.
      Overrides:
      prepareLevel in class SpaceInvadersLevel
      Parameters:
      id - String identifies level.
    • actionIfEgoCollidesWithEnemy

      void actionIfEgoCollidesWithEnemy(GameObject enemy, GameObject ego)
      Description copied from class: SpaceInvadersLevel
      implements behaviour of game when ego object is touching an enemy. It displays a text "AUAA!!" for a certain time on the game screen. Time span is defined as constant in SpaceInvadersLevel.BONUS_DURATION .
      Overrides:
      actionIfEgoCollidesWithEnemy in class SpaceInvadersLevel
      Parameters:
      enemy - the enemy that was hit
      ego - the ego object of the player
    • getStartupMessage

      protected String getStartupMessage()
      "Moving Hitting Objects Level!" is the message.
      Overrides:
      getStartupMessage in class SpaceInvadersLevel
      Returns:
      String "Moving & Hitting Objects Level!"