Class MoveableBoxComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.obstacles.MoveableBoxComponent
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.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()Called when the entity is created and registered.voidsetBaseGravityScale(float gravityScale) setCamera(com.badlogic.gdx.graphics.Camera camera) Sets the internal camera variable.voidsetPhysicsLayer(short physicsLayer) voidsetPlayerInRange(ColliderComponent collider) Responsible for the initial interaction on the box.voidsetVisible(boolean visible) voidupdate()Called once per frame of the game, and should be used for most component logic.Methods inherited from class com.csse3200.game.components.Component
dispose, earlyUpdate, getEntity, getPrio, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate
-
Constructor Details
-
MoveableBoxComponent
public MoveableBoxComponent()
-
-
Method Details
-
setCamera
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:ComponentCalled 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. -
setVisible
public void setVisible(boolean visible) -
setPlayerInRange
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:ComponentCalled once per frame of the game, and should be used for most component logic. Not called if component is disabled.
-