【问题标题】:get the window size in a DrawableGameComponent in XNA在 XNA 中的 DrawableGameComponent 中获取窗口大小
【发布时间】:2013-02-06 16:47:25
【问题描述】:

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

我尝试在我的Avatar 的覆盖方法Update 中获取窗口的尺寸。 但是我没有找到任何方法来获取窗口的宽度和高度。

GraphicsDeviceManager.DefaultBackBufferHeight 方法目前不起作用。

我的构造函数:

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

【问题讨论】:

  • 如果你追求渲染区域的大小,一般要viewport的大小。

标签: c# xna


【解决方案1】:

试试game.Window 窗口。 GameWindow 类包含您正在寻找的 ClientBounds 成员。

【讨论】:

    【解决方案2】:

    您可以通过这些属性获取活动Viewport 的宽度和高度。

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-10-03
      • 1970-01-01
      • 1970-01-01
      • 2010-10-31
      • 1970-01-01
      • 2010-10-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多