Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected override void Initialize()
- {
- // Make mouse visible
- this.IsMouseVisible = true;
- base.Initialize();
- }
- MouseState mouseStateCurrent, mouseStatePrevious;
- protected override void Update(GameTime gameTime)
- {
- // Allows the game to exit
- if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
- {
- this.Exit();
- }
- // Get current mouseState
- mouseStateCurrent = Mouse.GetState();
- // Left MouseClick
- if (mouseStateCurrent.LeftButton == ButtonState.Pressed)
- {
- // TODO when left mousebutton clicked
- }
- // Right MouseClick
- if (mouseStateCurrent.RightButton == ButtonState.Pressed && mouseStatePrevious.RightButton == ButtonState.Released)
- {
- //TODO when right mousebutton clicked
- }
- mouseStatePrevious = mouseStateCurrent;
- // Update
- base.Update(gameTime);
- }
- enum CLICKS{left=0, right, middle);
- public void mouseClick(){
- mouseClick(-1);
- }
- public void mouseClick(int manualClick){
- if(mouseStateCurrent.LeftButton == ButtonState.Pressed || manualClick == CLICKS.left)
- leftClick();
- }
- public void leftClick(){
- //do stuff
- }
- public void randomFunction(){
- //doing stuff
- mouseClick(CLICKS.left); //<-- will simulate a left click
- }
Add Comment
Please, Sign In to add comment