ZuneHD タッチパネルサンプル
using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.GamerServices; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Media; using Microsoft.Xna.Framework.Net; using Microsoft.Xna.Framework.Storage; namespace ZuneGame1 { public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch sprite; Texture2D texture; public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; TargetElapsedTime = TimeSpan.FromSeconds(1 / 30.0); } protected override void Initialize() { base.Initialize(); } protected override void LoadContent() { sprite = new SpriteBatch(GraphicsDevice); texture = Content.Load<Texture2D>("ball"); } protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) this.Exit(); base.Update(gameTime); } protected override void Draw(GameTime gameTime) { TouchCollection touchState = TouchPanel.GetState(); GraphicsDevice.Clear(Color.CornflowerBlue); sprite.Begin(SpriteBlendMode.Additive); foreach (TouchLocation touch in touchState ) sprite.Draw(texture, touch.Position, Color.White); sprite.End(); base.Draw( gameTime ); } } }
ここでタッチした個数分、スプライトを表示します。最大8個まで認識するみたいドキドキ
foreach (TouchLocation touch in touchState ) sprite.Draw(texture, touch.Position, Color.White);
きのうせいか、4個しか反応しないきがする・・・・・