也許我很瘋狂,但我想將我在XNA遊戲開發類中學到的一些邏輯合併到android/java遊戲編程中。例如,我使用Point而不是Vector2以編程方式操作圖形位置,並根據Android設備的dpi和方向調整圖形大小。簡單的數學運算符上的奇怪的java錯誤
我認爲在佈置圖形用戶界面並確定圖形應該從哪個文件夾(hdpi,ldpi或mdpi)中找到圖形的中心是一個很好的資源。不幸的是,Eclipse似乎對加號有問題。這很有趣,因爲我想執行一個簡單的數學運算:
運營商+未定義的參數類型android.graphics.Point,android.graphics.Point
//Java code was both copied & pasted as well as written to make sure Visual Studio
public Point Center()
{
return new Point(_frameWidth/2, _frameHeight/2)+_location;
}
//Original XNA code
//Determines the coordinates of a sprite's center
public Vector2 Center
{
get
{
return _location + new Vector2(_frameWidth/2, _frameHeight/2);
}
}
問題解決了 - 我在單獨的語句中添加了兩個點的X和Y值。走出C#和Java將是一個有趣的經驗,但我已經準備好迎接挑戰。謝謝! \t公共點中心() \t { \t \t INT X = _frameWidth/2 + _location.x; \t \t int y = _frameHeight/2 + _location.y; \t \t return new Point(x,y); \t} – Shortstuff81000 2012-02-15 13:37:32