O'Reilly logo

3D Game Development with Microsoft Silverlight 3 Beginner's Guide by Gastón C. Hillar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action—using the mouse manager in the game loop

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 the public partial class MainPage : UserControl, to hold an instance of the MouseManager 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required