Here are the docs for the Vector2 class which is supposed to encapsulate a 2D vector. http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Vector2.html
Based on the demonstration here and the api, is there a way of setting the fields of Vector2 without accessing them directly, after all "Encapsulation refers to the state of objects - objects encapsulate their state and hide it from the outside". - Encapsulation vs Abstraction? Is there a reason why this class doesn't have any getters and setters for x and y?
Here's how the author of the demo set the x and y fields. Demo - http://www.kilobolt.com/day-5-the-flight-of-the-dead---adding-the-bird.html
if (velocity.y > 200) {
velocity.y = 200;
}
and
public void onClick() {
velocity.y = -140;
}
which I think violates encapsulation in OO design. Is there a way around this?