【发布时间】:2014-05-17 01:02:10
【问题描述】:
我使用 monogame 框架开发游戏。 游戏本身的代码是从我之前编码的 XNA 代码转换而来的。 我为 800*480 分辨率开发游戏资源(背景等)。当我尝试以不同的设备分辨率(模拟器 720p)运行它时出现问题。 如何实际调整它的大小?
我已经添加了这段代码,但没有任何反应
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
this.Windows.ClientSizeChanged += Window_ClientSizeChanged;
}
void Window_ClientSizeChanged(object sender, EventArgs e)
{
int currentWidth = this.Window.ClientBounds.Width;
int currentHeight = this.Windows.ClientBounds.Height;
}
该代码只为 currentWidth 和 currentHeight 返回 0 值;
我也遵循此代码
this.Window.ClientSizeChanged += new EventHandler<EventArgs>(Window_ClientSizeChanged);
void Window_ClientSizeChanged(object sender, EventArgs e)
{
graphics.PreferredBackBufferWidth = Window.ClientBounds.Width;
graphics.PreferredBackBufferHeight = Window.ClientBounds.Height;
graphics.ApplyChanges();
}
但它有类似的结果。调整大小没有任何反应。 请指出我解决此问题的方法。因为我的游戏只能在 480*800 分辨率下运行。在其他分辨率下,它会显示一些空间。
之前谢谢。
【问题讨论】:
标签: windows-phone-8 xna monogame