本文整理汇总了C#中Microsoft.Xna.Framework.Input.MouseState类的典型用法代码示例。如果您正苦于以下问题:C# MouseState类的具体用法?C# MouseState怎么用?C# MouseState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MouseState类属于Microsoft.Xna.Framework.Input命名空间,在下文中一共展示了MouseState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public void Update(MouseState mouse)
{
rectangle = new Rectangle((int)position.X, (int)position.Y, (int)size.X, (int)size.Y);
Rectangle mouseRect = new Rectangle(mouse.X, mouse.Y, 1, 1);
if (mouseRect.Intersects(rectangle))
{
if (color.A == 255)
{
down = false;
}
if (color.A == 0)
{
down = true;
}
if (down == true)
{
color.A += 3;
}
else
{
color.A -= 3;
}
if (mouse.LeftButton == ButtonState.Pressed)
{
isClicked = true;
}
}
else if(color.A <255)
{
color.A += 3;
isClicked = false;
}
}
示例2: Update
public void Update()
{
MouseState state = Mouse.GetState();
if ((this.previousState.LeftButton == ButtonState.Released) && (state.LeftButton == ButtonState.Pressed))
{
this.gestures.OnNext(new Gesture(GestureType.LeftButtonDown, new Point((double)state.X, (double)state.Y)));
}
else if ((this.previousState.LeftButton == ButtonState.Pressed) && (state.LeftButton == ButtonState.Released))
{
this.gestures.OnNext(new Gesture(GestureType.LeftButtonUp, new Point((double)state.X, (double)state.Y)));
}
if ((state.X != this.previousState.X) || (state.Y != this.previousState.Y))
{
this.gestures.OnNext(new Gesture(GestureType.Move, new Point((double)state.X, (double)state.Y)));
}
if ((this.previousState.LeftButton == ButtonState.Pressed) && (state.LeftButton == ButtonState.Pressed))
{
this.gestures.OnNext(new Gesture(GestureType.FreeDrag, new Point((double)state.X, (double)state.Y), new Vector(state.X - previousState.X, state.Y - previousState.Y)));
}
this.previousState = state;
while (TouchPanel.IsGestureAvailable)
{
GestureSample sample = TouchPanel.ReadGesture();
if (sample.GestureType == XnaGestureType.FreeDrag)
{
this.gestures.OnNext(new Gesture(GestureType.FreeDrag, new Point((double)sample.Position.X, (double)sample.Position.Y), new Vector((double)sample.Delta.X, (double)sample.Delta.Y)));
}
}
}
示例3: Update
public override void Update(MouseState mouse)
{
foreach (Button button in Buttons)
{
button.Update(mouse);
}
}
示例4: Input
public Input(MouseState cms, MouseState pms, KeyboardState cks, KeyboardState pks)
{
Pms = pms;
Pks = pks;
Cms = cms;
Cks = cks;
}
示例5: Update
public void Update(KeyboardState keyboard, MouseState mouse, Engine engine)
{
// Rortational Origin
Rectangle originRect = new Rectangle((int) position.X, (int) position.Y,
(int) texture.Width, (int) texture.Height);
origin = new Vector2(originRect.Width / 2, originRect.Height / 2);
int playerSpeed = 2;
if (keyboard.IsKeyDown(Keys.A))
position.X -= playerSpeed;
if (keyboard.IsKeyDown(Keys.D))
position.X += playerSpeed;
if (keyboard.IsKeyDown(Keys.W))
position.Y -= playerSpeed;
if (keyboard.IsKeyDown(Keys.S))
position.Y += playerSpeed;
float deltaY = mouse.Y - position.Y;
float deltaX = mouse.X - position.X;
float radians = (float) Math.Atan2(deltaY, deltaX);
setRotation(radians);
}
示例6: Update
public void Update(MouseState mouse)
{
if (Enabled == true)
{
rectangle = new Rectangle((int)position.X, (int)position.Y,
(int)size.X, (int)size.Y);
Rectangle mouseRectangle = new Rectangle(mouse.X, mouse.Y, 1, 1);
if (mouseRectangle.Intersects(rectangle))
{
if (mouse.LeftButton == ButtonState.Pressed)
{
isClicked = true;
isSelected = true;
}
}
else
{
isClicked = false;
}
if (isSelected==true & isClicked==true)
{
Count();
}
}
wasSelected = isSelected;
count++;
}
示例7: Update
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
previousKeyState = currentKeyState;
currentKeyState = Keyboard.GetState();
previousMouseState = currentMouseState;
currentMouseState = Mouse.GetState();
// Exit
if (gameState == GameState.Quit || currentKeyState.IsKeyDown(Keys.Escape))
{
Exit();
}
if (gameState == GameState.TitleScreen)
{
titleScreen.Update(currentMouseState, previousMouseState, currentKeyState, previousKeyState);
gameState = titleScreen.gameState;
}
else if (gameState == GameState.Game)
{
character.Update(currentMouseState, previousMouseState, currentKeyState, previousKeyState, gameTime, map);
}
base.Update(gameTime);
}
示例8: InputHandler
}//InputManger
public void InputHandler(MouseState mst, GameTime gameTime)
{
if (!cG.IsActive) return;
mousestatus = mst;
HandleMouseLeftButton(gameTime);
if (mssButtonLeft == MsState.ButtonWasPressed)
{
if (mousestatus.X >= 0 && mousestatus.X <= 405)
{
if (mousestatus.Y >= 209 && mousestatus.Y <= 250)
{
cG.Toggle();
}//if
}//if
}//if
if (mssButtonLeft == MsState.ButtonWasPressed)
{
if (mousestatus.X >= 0 && mousestatus.X <= 628)
{
if (mousestatus.Y >= 304 && mousestatus.Y <= 350)
{
cG.CenterWindow();
}//if
}//if
}//if
}//InputHandler
示例9: Mouse
public override void Mouse(MouseState state, MouseState oldState)
{
var pos = CCDrawManager.ScreenToWorld(state.X, state.Y);
Vector2 position = new Vector2(pos.X, pos.Y);
if (state.RightButton == ButtonState.Pressed)
{
DrawCircleOnMap(position, -1);
_terrain.RegenerateTerrain();
DebugView.BeginCustomDraw();
DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Blue * 0.5f);
DebugView.EndCustomDraw();
}
if (state.LeftButton == ButtonState.Pressed)
{
DrawCircleOnMap(position, 1);
_terrain.RegenerateTerrain();
DebugView.BeginCustomDraw();
DebugView.DrawSolidCircle(position, _circleRadius, Vector2.UnitY, Color.Red * 0.5f);
DebugView.EndCustomDraw();
}
if (state.MiddleButton == ButtonState.Pressed)
{
Body circle = BodyFactory.CreateCircle(World, 1, 1);
circle.BodyType = BodyType.Dynamic;
circle.Position = position;
}
}
示例10: Update
public static void Update()
{
prevMouseState = mouseState;
mouseState = Mouse.GetState();
prevKeyboardState = keyboardState;
keyboardState = Keyboard.GetState();
}
示例11: cMenuOptionsWindowButton
public cMenuOptionsWindowButton(GraphicsDeviceManager gd, ContentManager cm)
{
_instance = this;
_graphics = gd;
_contentManager = cm;
mouseState = new MouseState();
_tabFont = cFontManager.Instance.getFont("Treb8");
_optionsbuttons = new List<cMenuButton>();
cSpriteManager.Instance.addTexture("Resources/Menu/optionswindowtab", "controls_tab");
_tcontrolsTab = new cMenuButton("controls_tab");
_tcontrolsTab.setOnClickListener(this);
_tcontrolsTab.Position = new Vector2(800 / 5 + 62, 600 / 2 - 157);
_optionsbuttons.Add(_tcontrolsTab);
cSpriteManager.Instance.addTexture("Resources/Menu/optionswindowtab", "sound_tab");
_tsoundTab = new cMenuButton("sound_tab");
_tsoundTab.setOnClickListener(this);
_tsoundTab.Position = new Vector2(800 / 5 + 132, 600 / 2 - 157);
_optionsbuttons.Add(_tsoundTab);
cSpriteManager.Instance.addTexture("Resources/Menu/optionswindowtab", "display_tab");
_tdisplayTab = new cMenuButton("display_tab");
_tdisplayTab.setOnClickListener(this);
_tdisplayTab.Position = new Vector2(800 / 5 + 202, 600 / 2 - 157);
_optionsbuttons.Add(_tdisplayTab);
cSpriteManager.Instance.addTexture("Resources/Menu/optionswindowtab", "cancel_button");
_tcancelButton = new cMenuButton("cancel_button");
_tcancelButton.setOnClickListener(this);
_tcancelButton.Position = new Vector2(_screenWidth - 231, _screenHeight / 2 + 183);
_optionsbuttons.Add(_tcancelButton);
}
示例12: InputController
public InputController()
{
m_DragArgs = new DragArgs();
m_LastMouseState = Mouse.GetState();
m_LastKeyboardState = Keyboard.GetState();
}
示例13: ClearState
public static void ClearState()
{
previousMouseState = Mouse.GetState();
currentMouseState = Mouse.GetState();
previousKeyState = Keyboard.GetState();
currentKeyState = Keyboard.GetState();
}
示例14: if
//Update. Checks where the mouse is, and returns a Vector2 for the camera to move when mouse is close to borders.
public Vector2 Update(int Width, int Height)
{
ms = Mouse.GetState();
Position = new Point(ms.X, ms.Y);
Vector2 mousePosition = new Vector2(ms.X, ms.Y);
Vector2 targetVector = Vector2.Zero;
if (ms.X < Width / 10)
{
targetVector.X = -4;
}
else if (ms.X > Width - Width / 10)
{
targetVector.X = 4;
}
if (ms.Y < Height / 10)
{
targetVector.Y = -4;
}
else if (ms.Y > Height - Height / 10)
{
targetVector.Y = 4;
}
return targetVector;
}
示例15: Update
public override void Update()
{
keyboard = Keyboard.GetState();
mouse = Mouse.GetState();
if (keyboard.IsKeyDown(Keys.W))
{
position.Y -= speed;
}
if (keyboard.IsKeyDown(Keys.A))
{
position.X -= speed;
}
if (keyboard.IsKeyDown(Keys.D))
{
position.X += speed;
}
if (keyboard.IsKeyDown(Keys.S))
{
position.Y += speed;
}
rotation = point_direction(position.X, position.Y, mouse.X,mouse.Y);
prevKeyBoard = keyboard;
prevMouse = mouse;
base.Update();
}