LibGDX Multiply Vector2 with float value

[亡魂溺海] 提交于 2019-12-24 00:55:56

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!