Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. MouseState previousMouseState;
  2. protected override void Initialize()
  3. {
  4. // TODO: Add your initialization logic here
  5. //store the current state of the mouse
  6. previousMouseState = Mouse.GetState();
  7. }
  8.  
  9.  
  10. protected override void Update(GameTime gameTime)
  11. {
  12. // .. other update code
  13.  
  14.  
  15. //is there a mouse click?
  16. //A mouse click occurs if the goes from a released state
  17. //in the previous frame to a pressed state
  18. //in the current frame
  19. if (previousMouseState.LeftButton == ButtonState.Released
  20. && Mouse.GetState().LeftButton == ButtonState.Pressed)
  21. {
  22. //do your mouse click response...
  23.  
  24. }
  25.  
  26. //save the current mouse state for the next frame
  27. // the current
  28. previousMouseState = Mouse.GetState();
  29.  
  30. base.Update(gameTime);
  31. }
  32.  
  33. //Create this variable
  34. MouseState mouseState;
  35.  
  36. mouseState = Mouse.GetState();
  37.  
  38. if (mouse.RightButton == ButtonState.Pressed)
  39. {
  40. //Do Stuff
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement