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
默认情况下,活动的视口
将是整个窗口。如果您关注渲染区域的大小,则通常需要视口的大小。如果您关注渲染区域的大小,则通常需要视口的大小。