- Object
-
- Force
-
public class Force extends Object
Represents a force.- Since:
- 1.0.0
- Version:
- 5.0.0
- Author:
- William Bittle
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Vector2
getForce()
Returns the force vector.boolean
isComplete(double elapsedTime)
Returns true if this force should be removed.void
set(double x, double y)
Sets thisForce
to the given components.void
set(Force force)
void
set(Vector2 force)
String
toString()
-
-
-
Field Detail
-
force
protected Vector2 force
The force to apply
-
-
Constructor Detail
-
Force
public Force()
Default constructor.
-
Force
public Force(double x, double y)
Creates a newForce
using the x and y components.- Parameters:
x
- the x componenty
- the y component
-
Force
public Force(Vector2 force)
- Parameters:
force
- the forceVector2
- Throws:
NullPointerException
- if force is null
-
Force
public Force(Force force)
Copy constructor.- Parameters:
force
- theForce
to copy- Throws:
NullPointerException
- if force is null
-
-
Method Detail
-
set
public void set(double x, double y)
Sets thisForce
to the given components.- Parameters:
x
- the x componenty
- the y component
-
set
public void set(Vector2 force)
- Parameters:
force
- the forceVector2
- Throws:
NullPointerException
- if force is null
-
set
public void set(Force force)
- Parameters:
force
- theForce
to copy- Throws:
NullPointerException
- if force is null
-
isComplete
public boolean isComplete(double elapsedTime)
Returns true if this force should be removed.Implement this method to create
Force
objects that are not cleared during the accumulation step.The default implementation always returns true.
- Parameters:
elapsedTime
- the elapsed time since the last call to this method- Returns:
- boolean true if this force should be removed
- Since:
- 3.1.0
-
-