どのように私は、XNAに窓/画面サイズを設定するのですか?

StackOverflow https://stackoverflow.com/questions/720429

  •  23-08-2019
  •  | 
  •  

質問

どのように私は、XNAでウィンドウのサイズを調整することができます。

それは800×600の解像度で起動デフォルトます。

役に立ちましたか?

解決 2

私はあなたが設定する必要があることが分かった。

GraphicDevice.PreferredBackBufferHeight = height;
GraphicDevice.PreferredBackBufferWidth = width;

あなたはそれが動作ゲームクラスのコンストラクタでこれを行うが、あなたは、コンストラクタの外にこれを行うしようとすると、あなたも呼び出す必要がある場合には、

GraphicsDevice.ApplyChanges();

また、使用することができます(実際にデバッグ中に正常に動作していないもの)フルスクリーンを持っている。

if (!GraphicsDevice.IsFullScreen)
   GraphicsDevice.ToggleFullScreen();

他のヒント

このプロパティは、現在GraphicsDeviceManagerで発見されたXNA 4.0の通り。 すなわち。このコードは、あなたのゲームのコンストラクタで行くだろう。

graphics = new GraphicsDeviceManager(this);
graphics.IsFullScreen = false;
graphics.PreferredBackBufferHeight = 340;
graphics.PreferredBackBufferWidth = 480;

// if changing GraphicsDeviceManager properties outside 
// your game constructor also call:
// graphics.ApplyChanges();

あなたはこれを見なければならない、 の<のhref =」 http://forums.xna.com/forums/p/1031/107718.aspx」のrel = "nofollowをnoreferrer"> http://forums.xna.com/forums/p/1031/107718.aspxするます。

このソリューションは、XNA 3.0で動作します。ちょうどあなたのゲームオブジェクトのコンストラクタに入れます:

// Resize the screen to 1024 x 768.
IntPtr ptr = this.Window.Handle;
System.Windows.Forms.Form form = (System.Windows.Forms.Form)System.Windows.Forms.Control.FromHandle(ptr);
form.Size = new System.Drawing.Size(1024, 768);

graphics.PreferredBackBufferWidth = 1024;
graphics.PreferredBackBufferHeight = 768;

graphics.ApplyChanges();
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top