C# 获取XNA中DrawableGameComponent中的窗口大小

C# 获取XNA中DrawableGameComponent中的窗口大小,c#,xna,C#,Xna,我有一个Avatar对象继承自Microsoft.Xna.Framework.DrawableGameComponent 我尝试在我的化身的覆盖方法Update中获取窗口的维度。 但是我找不到任何方法来计算窗户的宽度和高度 方法GraphicsDeviceManager.DefaultBackBufferHeight到目前为止不起作用 我的构造函数: public Avatar(Game game) : base(game) { // TODO:

我有一个
Avatar
对象继承自
Microsoft.Xna.Framework.DrawableGameComponent

我尝试在我的
化身的覆盖方法
Update
中获取窗口的维度。 但是我找不到任何方法来计算窗户的宽度和高度

方法
GraphicsDeviceManager.DefaultBackBufferHeight
到目前为止不起作用

我的构造函数:

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

试着打开窗户。该类具有您要查找的
ClientBounds
成员。

尝试该窗口。该类具有您正在查找的
ClientBounds
成员。

您可以使用这些属性获取活动
视口的宽度和高度

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

默认情况下,活动的
视口将是整个窗口。

您可以使用这些属性获取活动的
视口的宽度和高度

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

默认情况下,活动的
视口
将是整个窗口。

如果您关注渲染区域的大小,则通常需要视口的大小。如果您关注渲染区域的大小,则通常需要视口的大小。