【问题标题】:How do I make my XNA game fullscreen while maintaining aspect ratio and centered?如何在保持纵横比和居中的同时使我的 XNA 游戏全屏显示?
【发布时间】:2013-03-31 06:49:27
【问题描述】:

我找不到任何好的教程来制作全屏游戏同时保持纵横比。用文字来形容有点难,我分两张图给大家看看吧。

我目前拥有的:
https://dl.dropbox.com/u/51911679/Pictures/Whocares/Screenshots/whatIgot.jpg

我想要什么:
https://dl.dropbox.com/u/51911679/Pictures/Whocares/Screenshots/whatIwant.jpg

【问题讨论】:

  • 仅供参考,不要使用外部链接来托管您的图像,您可以将它们嵌入您的问题中。很多人在工作中无法访问诸如保管箱之类的地方。

标签: c# xna fullscreen aspect-ratio


【解决方案1】:

GraphicsDeviceManager 类可以为您处理大部分问题:

    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        graphics.IsFullScreen = true;
        graphics.PreferredBackBufferWidth = 1280;
        graphics.PreferredBackBufferHeight = 720;

        //...
    }

现在,您必须确保您实际上是在您的 SpriteBatch 坐标中绘制整个屏幕(基于您的宽度和高度)。

【讨论】:

  • 有没有办法动态缩放所有内容以适应不同的分辨率——而不是去每个矩形并说 rectangle.width=screenwidth/somenumber;
  • 如果您为所有呼叫指定了不同的分辨率,您可以简单地全部更改(只更改一次,然后开始定位新的),或尝试my answer here
猜你喜欢
  • 2023-04-04
  • 2021-12-09
  • 2015-07-30
  • 1970-01-01
  • 2017-04-04
  • 2015-01-29
  • 2016-02-15
  • 1970-01-01
  • 2012-03-03
相关资源
最近更新 更多