ニュース速報XNA360

How to: プレイヤーによるゲーム画面のリサイズ

最終更新:

匿名ユーザー

- view
だれでも歓迎! 編集
Demonstrates how to let the player resize the game window.
ウィンドウのサイズをプレーヤーが変えられるようにする方法を説明します。

リサイズ可能なプレーヤーウィンドウをゲームに追加する。

1. Gameクラスを派生させる
2. Game.GameWindow.AllowUserResizingをtrueにセットする
3. ClientSizeChangedイベントのイベントハンドラを自分で書く。

C#

+ ...
Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Storage;

public class Game1 : Microsoft.Xna.Framework.Game
{
   GraphicsDeviceManager graphics;
   ContentManager content;


   public Game1()
   {
       graphics = new GraphicsDeviceManager(this);
       content = new ContentManager(Services);
       Window.AllowUserResizing = true;

       // ウィンドウの ClientSizeChangedイベントにハンドラを追加.
       Window.ClientSizeChanged += new EventHandler(Window_ClientSizeChanged);
   }

   void Window_ClientSizeChanged(object sender, EventArgs e)
   {
       // Make changes to handle the new window size.
   }


   protected override void Initialize()
   {
       // TODO: Add your initialization logic here

       base.Initialize();
   }


   protected override void LoadGraphicsContent(bool loadAllContent)
   {
       if (loadAllContent)
       {
           // TODO: Load any ResourceManagementMode.Automatic content
       }

       // TODO: Load any ResourceManagementMode.Manual content
   }


   protected override void UnloadGraphicsContent(bool unloadAllContent)
   {
       if (unloadAllContent == true)
       {
           content.Unload();
       }
   }


   protected override void Update(GameTime gameTime)
   {
       // Allows the default game to exit on Xbox 360 and Windows
       if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
           this.Exit();

       // TODO: Add your update logic here

       base.Update(gameTime);
   }


   protected override void Draw(GameTime gameTime)
   {
       graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

       // TODO: Add your drawing code here

       base.Draw(gameTime);
   }
}

タグ:

+ タグ編集
  • タグ:
ウィキ募集バナー