Package de.gurkenlabs.litiengine.physics
Class MovementController<T extends IMobileEntity>
java.lang.Object
de.gurkenlabs.litiengine.physics.MovementController<T>
- All Implemented Interfaces:
IEntityController,IUpdateable,IMovementController
- Direct Known Subclasses:
GamepadEntityController,KeyboardEntityController,MousePathController
public class MovementController<T extends IMobileEntity>
extends Object
implements IMovementController
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidApply the force to the entity.voidattach()voiddetach()Gets the active forces.floatgetDx()Gets the delta x for each horizontal movement.floatgetDy()Sets the delta y for each vertical movement.doubledoubleGet the current velocity.voidprotected booleanprotected voidmoveEntity(double deltaX, double deltaY) voidonMovementCheck(Predicate<IMobileEntity> predicate) Checks given conditions before moving.voidsetDx(float dx) Gets the delta x for each horizontal movement.voidsetDy(float dy) Sets the delta y for each vertical movement.voidsetVelocity(double velocity) Sets the current velocity.voidupdate()This method is called by the game loop on all objects that are attached to the loop.
-
Constructor Details
-
MovementController
-
-
Method Details
-
attach
public void attach()- Specified by:
attachin interfaceIEntityController
-
detach
public void detach()- Specified by:
detachin interfaceIEntityController
-
apply
Description copied from interface:IMovementControllerApply the force to the entity.- Specified by:
applyin interfaceIMovementController- Parameters:
force- the force being applied to the entity
-
getActiveForces
Description copied from interface:IMovementControllerGets the active forces.- Specified by:
getActiveForcesin interfaceIMovementController- Returns:
- the active forces
-
getEntity
- Specified by:
getEntityin interfaceIEntityController
-
getDx
public float getDx()Description copied from interface:IMovementControllerGets the delta x for each horizontal movement.- Specified by:
getDxin interfaceIMovementController- Returns:
- the dx
-
setDx
public void setDx(float dx) Description copied from interface:IMovementControllerGets the delta x for each horizontal movement.- Specified by:
setDxin interfaceIMovementController- Parameters:
dx- the new dx
-
getDy
public float getDy()Description copied from interface:IMovementControllerSets the delta y for each vertical movement.- Specified by:
getDyin interfaceIMovementController- Returns:
- the dy
-
setDy
public void setDy(float dy) Description copied from interface:IMovementControllerSets the delta y for each vertical movement.- Specified by:
setDyin interfaceIMovementController- Parameters:
dy- the new dy
-
onMovementCheck
Description copied from interface:IMovementControllerChecks given conditions before moving.- Specified by:
onMovementCheckin interfaceIMovementController- Parameters:
predicate- the conditions that need to apply before moving. If they don't apply, the entity won't be moved.
-
update
public void update()Description copied from interface:IUpdateableThis method is called by the game loop on all objects that are attached to the loop. It's called on every tick of the loop and the frequency can be configured using theClientConfiguration.- Specified by:
updatein interfaceIUpdateable- See Also:
-
handleMovement
public void handleMovement() -
getForce
- Specified by:
getForcein interfaceIMovementController
-
getMoveAngle
public double getMoveAngle()- Specified by:
getMoveAnglein interfaceIMovementController
-
setVelocity
public void setVelocity(double velocity) Description copied from interface:IMovementControllerSets the current velocity.- Specified by:
setVelocityin interfaceIMovementController- Parameters:
velocity- The velocity to set.
-
getVelocity
public double getVelocity()Description copied from interface:IMovementControllerGet the current velocity.- Specified by:
getVelocityin interfaceIMovementController- Returns:
- The current velocity.
-
moveEntity
protected void moveEntity(double deltaX, double deltaY) -
isMovementAllowed
protected boolean isMovementAllowed()
-