[英]How can i get the width and height of the screen in xna?
所以在我的2d塔防游戏中,我需要获得屏幕的分辨率,以便在我的缩放矩阵中使用。 但是我找不到一种有效的方法。 我试过了:
_graphics.GraphicsDevice.Viewport.Width
和
GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width
//It always crashes the game
_graphics.PreferredBackBufferWidth
//Also crashes
这是我的确切代码
screenscalex = (float) *whatever i put here* / 1366f;
谢谢!
确保在调用initialize后进行这些检查。 在检查这些项目之前,必须初始化图形设备。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.