Class PhysicsMovementComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.physics.components.PhysicsMovementComponent
- All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable,MovementController
Movement controller for a physics-based entity.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.badlogic.gdx.math.Vector2voidcreate()Called when the entity is created and registered.booleancom.badlogic.gdx.math.Vector2booleanvoidsetMaxSpeed(com.badlogic.gdx.math.Vector2 newSpeed) voidsetMoving(boolean movementEnabled) Enable/disable movement for the controller.voidsetTarget(com.badlogic.gdx.math.Vector2 target) Set a target to move towards.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, read, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, write
-
Constructor Details
-
PhysicsMovementComponent
public PhysicsMovementComponent()
-
-
Method Details
-
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. -
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. -
setMoving
public void setMoving(boolean movementEnabled) Enable/disable movement for the controller. Disabling will immediately set velocity to 0.- Specified by:
setMovingin interfaceMovementController- Parameters:
movementEnabled- true to enable movement, false otherwise
-
getTarget
public com.badlogic.gdx.math.Vector2 getTarget()- Specified by:
getTargetin interfaceMovementController- Returns:
- Target position in the world
-
getMoving
public boolean getMoving()- Specified by:
getMovingin interfaceMovementController- Returns:
- True when movement enabled, false when disabled
-
setTarget
public void setTarget(com.badlogic.gdx.math.Vector2 target) Set a target to move towards. The entity will be steered towards it in a straight line, not using pathfinding or avoiding other entities.- Specified by:
setTargetin interfaceMovementController- Parameters:
target- target position
-
calculateVelocityVector
public com.badlogic.gdx.math.Vector2 calculateVelocityVector() -
setMaxSpeed
public void setMaxSpeed(com.badlogic.gdx.math.Vector2 newSpeed) -
isStunned
public boolean isStunned()
-