2014-02-18 30 views
0

所以我寫了一個方法來爲我做這個,但我覺得這應該已經存在某種意義上。如何更改Vector2?

position = ChangeVector(250.0f + somefloat, 100.0f + someotherfloat); 


public Vector2 ChangeVector(float X, float Y) 
{ 
    Vector2 Vector = new Vector2(); 
    Vector.X = X; 
    Vector.Y = Y; 
    return Vector; 
} 

我覺得我應該只可以鍵入類似:

position = (250.0f + somefloat, 100.0f + someotherfloat); 

這更多的是出於好奇心比什麼都重要,我做不做工精細的方式,它只是似乎凌亂。

回答

1

可以使用overloaded constructorVector2 Constructor (Single, Single)

position = new Vector2(250.0f + somefloat, 100.0f + someotherfloat); 
+1

燁,做的伎倆,感謝 – user2056166

+0

根據記錄,您也可以只添加兩個載體:'VAR的結果=位置+新Vector2(250.0f,100.0 F);' –