Class Force
java.lang.Object
de.gurkenlabs.litiengine.physics.Force
- Direct Known Subclasses:
GravityForce,StickyForce
Represents a force in the physics engine. A force has a location, strength, size, and various properties that determine its behavior.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if the force should be canceled on collision.booleanChecks if the force should be canceled when the target is reached.voidend()Ends the force, marking it as ended.Gets the identifier for the force.Gets the location.floatGets the strength in pixels per second.booleanhasEnded()Checks if the force has ended.booleanhasReached(ICollisionEntity entity) Checks if the force has reached the specified entity.voidsetCancelOnCollision(boolean cancelOnCollision) Sets whether the force should be canceled on collision.voidsetCancelOnReached(boolean cancelOnReached) Sets whether the force should be canceled when the target is reached.voidsetIdentifier(String identifier) Sets the identifier for the force.voidsetLocation(Point2D location) Sets the location of the force.voidsetStrength(float strength) Sets the strength of the force in pixels per second.toString()Returns a string representation of the Force object.
-
Constructor Details
-
Force
Instantiates a new force.- Parameters:
location- The location where the force is originating fromstrength- The strength/intensity of this force instancesize- The size of this force (used to determine if/when an entity has reached the force)
-
-
Method Details
-
cancelOnCollision
public boolean cancelOnCollision()Checks if the force should be canceled on collision.- Returns:
- true if the force should be canceled on collision, false otherwise
-
cancelOnReached
public boolean cancelOnReached()Checks if the force should be canceled when the target is reached.- Returns:
- true if the force should be canceled when the target is reached, false otherwise
-
end
public void end()Ends the force, marking it as ended. -
getLocation
-
getStrength
public float getStrength()Gets the strength in pixels per second.- Returns:
- the strength in pixels per seconds
-
getIdentifier
Gets the identifier for the force.- Returns:
- the identifier of the force
-
hasEnded
public boolean hasEnded()Checks if the force has ended.- Returns:
- true if the force has ended, false otherwise
-
hasReached
Checks if the force has reached the specified entity.- Parameters:
entity- the entity to check against- Returns:
- true if the force has reached the entity, false otherwise
-
setCancelOnCollision
public void setCancelOnCollision(boolean cancelOnCollision) Sets whether the force should be canceled on collision.- Parameters:
cancelOnCollision- true if the force should be canceled on collision, false otherwise
-
setCancelOnReached
public void setCancelOnReached(boolean cancelOnReached) Sets whether the force should be canceled when the target is reached.- Parameters:
cancelOnReached- true if the force should be canceled when the target is reached, false otherwise
-
setLocation
Sets the location of the force.- Parameters:
location- the new location of the force
-
setStrength
public void setStrength(float strength) Sets the strength of the force in pixels per second.- Parameters:
strength- the new strength of the force
-
setIdentifier
Sets the identifier for the force.- Parameters:
identifier- the new identifier for the force
-
toString
-