INPUT(マウス編)
■マウスの入力がX360に必要なのかわかりませんが、マウスの入力もちゃんとサポートされているようです。キーボードとマウスのインターフェイスがあるのでX360上でTOOLが作れたらいいなー
namespace WindowsGame { public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; ContentManager content; private SpriteBatch sprite; private Texture2D texture; private Vector2 myPos = new Vector2( 0, 0 ); public Game1() { graphics = new GraphicsDeviceManager(this); content = new ContentManager(Services); } protected override void LoadGraphicsContent(bool loadAllContent) { if (loadAllContent) { sprite = new SpriteBatch(graphics.GraphicsDevice); texture = content.Load<Texture2D>("mimi"); } } protected override void Update(GameTime gameTime) { mouseInput(); base.Update(gameTime); } protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear(Color.CornflowerBlue); sprite.Begin(); sprite.Draw(texture, myPos , Color.White); sprite.End(); base.Draw(gameTime); } /// <summary> /// マウス入力 /// </summary> private void mouseInput() { MouseState mouseState = Mouse.GetState(); if (mouseState.LeftButton == ButtonState.Pressed) { // 左ボタンが押された } if (mouseState.RightButton == ButtonState.Pressed) { // 右ボタンが押された } // マウス座標取得 myPos = new Vector2( mouseState.X, mouseState.Y ); } } }
今回は使わなかったのですが、マウスカーソルを表示するのは以下の設定が必要です。
IsMouseVisible = true;
■実行すると
マウスの位置にあわせ、キャラクターが移動します。