问题
Is there a way to multiply a Vector2 with a float value? I used to do this in XNA to calculate movement by multiplying a normalized direction vector with a velocity float. This pretty much is the last step in my code to make things work but there does not seem a multiply function for a Vector2 that accepts a float value. I could just mulltiply x and y manually but there should be a method for this i don't know about.
回答1:
From http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Vector2.html :
scl
public Vector2 scl(float x,
float y)
Multiplies this vector by a scalar
Returns:
This vector for chaining
So I guess it's called "scale". If you want to multiply the entire vector, just use the same value for x and y.
来源:https://stackoverflow.com/questions/24354661/libgdx-multiply-vector2-with-float-value