T - Type of vector, either 2D or 3D, implementing the Vector interfacepublic static interface Jump.GravityComponentHandler<T extends com.badlogic.gdx.math.Vector<T>>
GravityComponentHandler is aware of the axis along which the gravity acts.| Modifier and Type | Method and Description |
|---|---|
float |
getComponent(T vector)
Returns the component of the given vector along which the gravity operates.
|
void |
setComponent(T vector,
float value)
Sets the component of the given vector along which the gravity operates.
|
float getComponent(T vector)
Assuming a 3D coordinate system where the gravity is acting along the y-axis, this method will be implemented as follows:
public float getComponent (Vector3 vector) {
return vector.y;
}
Of course, the equivalent 2D implementation will use Vector2 instead of Vector3.vector - the vectorvoid setComponent(T vector, float value)
Assuming a 3D coordinate system where the gravity is acting along the y-axis, this method will be implemented as follows:
public void setComponent (Vector3 vector, float value) {
vector.y = value;
}
Of course, the equivalent 2D implementation will use Vector2 instead of Vector3.vector - the vectorvalue - the value of the component affected by gravity