Class MoveableBoxComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.obstacles.MoveableBoxComponent

public class MoveableBoxComponent extends Component
This component is used to do the interactions between the player and the box entity. It is responsible for both interpreting the interaction when the player presses teh interact button and also for moving the host entity. It does this by taking the mouse pos in the world and slowly moving the box towards the mouse (within a max dist), the box also rotates based on the direction of where the mouse is.
  • Constructor Details

    • MoveableBoxComponent

      public MoveableBoxComponent()
  • Method Details

    • setCamera

      public MoveableBoxComponent setCamera(com.badlogic.gdx.graphics.Camera camera)
      Sets the internal camera variable. This camera variable is then used when doing mouse pointer calculations
      Parameters:
      camera - the world camera
      Returns:
      this component
    • setPhysicsLayer

      public void setPhysicsLayer(short physicsLayer)
    • setBaseGravityScale

      public void setBaseGravityScale(float gravityScale)
    • create

      public void create()
      Description copied from class: Component
      Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.
      Overrides:
      create in class Component
    • setVisible

      public void setVisible(boolean visible)
    • setPlayerInRange

      public void setPlayerInRange(ColliderComponent collider)
      Responsible for the initial interaction on the box. This has to be used to locate the player and then store it locally, it also sets up the required listener.
      Parameters:
      collider - the player collider
    • update

      public void update()
      Description copied from class: Component
      Called once per frame of the game, and should be used for most component logic. Not called if component is disabled.
      Overrides:
      update in class Component