2012-03-15 64 views

回答

6

您需要添加對System.Windows.FormsSystem.Drawing(如Steve H所指出的)的引用,然後在構造函數之外的某處執行以下操作,例如在Initialize覆蓋中。

var form = (System.Windows.Forms.Form)System.Windows.Forms.Control.FromHandle(this.Window.Handle); 
form.Location = new System.Drawing.Point(0, 0); 

我們在代碼中擁有整個命名空間的原因是爲了避免類名衝突(同樣,正如Steve H指出的那樣)。

+2

點還需要對System.Drawing的引用。另外,最好不要爲這兩個引用添加使用語句,因爲它們都可以與Xna類型(例如Point)產生歧義。 – 2012-03-15 22:25:22

+0

所以你說我需要把'使用System.Windows.Forms'在代碼的開始?我得到一個命名空間錯誤。可能是一個簡單的答案,我只是新的。 – TankorSmash 2012-08-13 14:55:20

+0

@TankorSmash,你需要在你的解決方案資源管理器中右擊'References',點擊'Add Reference ...',然後瀏覽到'System.Windows.Forms',然後執行相同的操作,但是使用System。 Drawing'。 – 2012-08-13 17:08:15

5

要更新這個問題,對於MonoGame 3.4(可能更早),你可以簡單地做

this.Window.Position = new Point(x, y);

不需要反映到OpenTK東西似乎