Now, it is time to make the necessary changes to the game loop in order to use our new mouse manager. We will deactivate the keyboard manager and replace it with the mouse manager:
1. Stay in the
SilverlightInvaders2DVector
project.2. Open
MainPage.xaml.cs
.3. Add the following
private
variables in thepublic partial class MainPage : UserControl
, to hold an instance of theMouseManager
class and the previous mouse position:private MouseManager _mouseManager; private Point oldMousePoint = new Point(0,0);
4. Add the following
private
method to check the mouse movement using the new mouse manager and to move the ship according to the vectors.private void CheckMouse() { // By default, the ship will not move if there is no mouse activity _ship.GoNowhere(); Point mousePoint = MouseManager.GetMousePosition(); // Move the ship when the button is down if (mousePoint.X < oldMousePoint.X) _ship.GoLeft(); if (mousePoint.X > oldMousePoint...