In my past few posts, I have shown how to create a really, really simple game, it isn’t all that fun, but with the exception of scoring and writing on the screen, it shows most of the simple elements that can be used in a game.
After an excellent online talk by the dynamic and organized Dan Waters (a compliment I can safely state since it is very unlikely he reads my blog, I wouldn’t want him to get a big head), I realized that I need to change my general approach to use the multi-touch API, instead of the Mouse.
It could be (note: my opinion) that Mouse Input may not handled in the future releases of Win Phone. Using the code from BoundingBox.Intersects versus rectangle.Intersect blog, make the following modifications
//Start code
protected override void Update(GameTime gameTime) { CollisionTest(); //HandleInput(); HandleInputMultiTouch(); base.Update(gameTime); }
private void CollisionTest() { if (r_PinkGirl.Intersects(r_PlanetBoy)) { b_collision = true; } }
private void HandleInput() { MouseState currentMouse = Mouse.GetState(); r_PinkGirl.X = currentMouse.X; r_PinkGirl.Y = currentMouse.Y; }
private void HandleInputMultiTouch() { TouchCollection touchCollection = TouchPanel.GetState(); foreach (TouchLocation touchLoc in touchCollection) { if ((touchLoc.State == TouchLocationState.Pressed) || (touchLoc.State == TouchLocationState.Moved)) { r_PlanetBoy.X = (int)touchLoc.Position.X; r_PlanetBoy.Y = (int)touchLoc.Position.Y; } } }
//end code
Legal Note:
Restrictions: