4
votes

I am attempting to multiply the type "Vector2" by a scalar of value delta and type float. Information on the type Vector2 can be found here:

http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/class-use/Vector2.html

Specifically on that page, I am referencing:

Vector2 --- Vector2.scl(float scalar) Multiplies this vector by a scalar

position is a Vector2 velocity is a Vector2

I am being given the error: "The method scl(float) is undefined for the type Vector2"

public void update(float delta) {
    position.add(velocity.cpy()).scl(delta); 
}
1

1 Answers

6
votes

The Vector2.scl method is new. You must be using an older version of Libgdx. The method is called mul in older versions (this method still exists in the newer Libgdx, but is @deprecated):

See http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Vector2.html#mul(float)