2013-02-06 87 views
0

我從Microsoft.Xna.Framework.DrawableGameComponent獲得在DrawableGameComponent窗口大小在XNA

繼承了Avatar對象我試圖讓窗口的尺寸在我Avatar的overrided方法Update。 但我沒有找到任何方法來獲得窗口的寬度和高度。

方法GraphicsDeviceManager.DefaultBackBufferHeight迄今爲止不起作用。

我的構造函數:

public Avatar(Game game) 
     : base(game) 
    { 
     // TODO: Construct any child components here 
    } 
+1

如果您在渲染區域的大小之後,通常需要* viewport *的大小。 –

回答

2

您可以使用這些屬性獲取活動Viewport的寬度和高度。

this.GraphicsDevice.Viewport.Width 
this.GraphicsDevice.Viewport.Height 

默認情況下,活動的Viewport將是整個窗口。

相關問題