locked
Mouse Movement RRS feed

  • Question

  • Hey guys,

     Right now I'm planning a little space shooter game. The first thing I want to do is a moving ship. The ship should be moved by the mouse. The ship's coordinates are not equivalent to the mouse position, the ship is only moving half the pixels of the mousecursor. And here is my problem. It is possible to move the mouse outside of the control. In this case I receive no longer any mouse_move events. I need something that lets me get the mouse position even if the cursor is out of the screen.

     Does anyone have an idea?

    Wednesday, December 3, 2008 8:12 AM

Answers

All replies

  • Silverlight will not fire any events outside the control area. It will be tricky, but you can have a mouse move listener on your web page and let the JavaScript code in your HTML invoke the c#, also consider designing the game to have full width of the page, or being played in full screen mode.

    Wednesday, December 3, 2008 8:35 AM
  •  Yes, I've thought about this. But I'm afraid this won't be enough. See if the ship moves only half the pixels of the mouse cursor (In order to slow down the ship) it will require the mouse to be moved even outside the browser window.

    I think it's possible in flash. You click inside a flash applet, the mouse cursor disappears, and the only way to move it out is something like pressing ALT or the windows key. I guess this would be the perfect solution for my problem.

    Wednesday, December 3, 2008 8:46 AM
  •  Actually Flash has the same issue. Developers address this issue using JavaScript in the browser too. Check this forum thread for more information

    http://www.actionscript.org/forums/showthread.php3?t=136109&highlight=detect+mouse

    Wednesday, December 3, 2008 9:00 AM
  •  Ok, many thanks for your quick reply. I marked your last post as answer. Seems like I have to create my game with cursor controls or by using C#. I don't think the user will have a good experience if I implement the workaround.

    Wednesday, December 3, 2008 9:06 AM