Multiplying Vector2 by Scalar (LibGDX)

I am trying to multiply the type "Vector2" by a scalar of delta and type float values. Information about the Vector2 type can be found here:

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

In particular, on this page I refer to:

Vector2 --- Vector2.scl (floating scalar) Multiplies this vector by scalar

position is vector2 speed is vector2

I get an error: "The scl (float) method is undefined for type Vector2"

public void update(float delta) { position.add(velocity.cpy()).scl(delta); } 
+4
source share
1 answer

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

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

+5
source

Source: https://habr.com/ru/post/1482833/


All Articles