本文整理汇总了C#中Microsoft.Xna.Framework.Input.MouseState类的典型用法代码示例。如果您正苦于以下问题:C# MouseState类的具体用法?C# MouseState怎么用?C# MouseState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MouseState类属于Microsoft.Xna.Framework.Input命名空间,在下文中一共展示了MouseState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
}
开发者ID:naturalna,项目名称:OOPPrinciples,代码行数:33,代码来源:CButton.cs
示例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)));
}
}
}
开发者ID:redbadger,项目名称:XPF,代码行数:30,代码来源:InputManagerWindows.cs
示例3: Update
public override void Update(MouseState mouse)
{
foreach (Button button in Buttons)
{
button.Update(mouse);
}
}
开发者ID:Rattatak,项目名称:LeGame,代码行数:7,代码来源:DeathScreen.cs
示例4: Input
public Input(MouseState cms, MouseState pms, KeyboardState cks, KeyboardState pks)
{
Pms = pms;
Pks = pks;
Cms = cms;
Cks = cks;
}
开发者ID:JaapSuter,项目名称:Pentacorn,代码行数:7,代码来源:Input.cs
示例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);
}
开发者ID:nfsz,项目名称:Zombie,代码行数:26,代码来源:Player.cs
示例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++;
}
开发者ID:Ranoar,项目名称:LoL-eSports-Manager,代码行数:35,代码来源:cChampBtn.cs
示例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);
}
开发者ID:Hrodgeir,项目名称:TileGame,代码行数:30,代码来源:TileGame.cs
示例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
开发者ID:GhostTap,项目名称:MonoGame,代码行数:32,代码来源:InputManager.cs
示例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;
}
}
开发者ID:KerwinMa,项目名称:CocosSharp,代码行数:32,代码来源:DestructibleTerrainMSTest.cs
示例10: Update
public static void Update()
{
prevMouseState = mouseState;
mouseState = Mouse.GetState();
prevKeyboardState = keyboardState;
keyboardState = Keyboard.GetState();
}
开发者ID:kylox,项目名称:Templar,代码行数:7,代码来源:Data.cs
示例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);
}
开发者ID:mikecann,项目名称:Portal2D-XNA,代码行数:30,代码来源:cMenuOptionsWindowButton.cs
示例12: InputController
public InputController()
{
m_DragArgs = new DragArgs();
m_LastMouseState = Mouse.GetState();
m_LastKeyboardState = Keyboard.GetState();
}
开发者ID:acid1789,项目名称:Happiness,代码行数:7,代码来源:InputController.cs
示例13: ClearState
public static void ClearState()
{
previousMouseState = Mouse.GetState();
currentMouseState = Mouse.GetState();
previousKeyState = Keyboard.GetState();
currentKeyState = Keyboard.GetState();
}
开发者ID:TrevorG6677,项目名称:s00146980Assessment2dFinalProject,代码行数:7,代码来源:InputEngine.cs
示例14: Update
public override void Update(GameTime gameTime)
{
_previousMouseState = _currentMouseState;
_currentMouseState = Mouse.GetState();
_previousBugBox = _bugBox;
if (drawEnemyBug)
{
Position = new Point(Position.X, Position.Y);
_bugBox = new Rectangle(this.Position.X, this.Position.Y, Drawable.Art.Width, Drawable.Art.Height);
}
if (!drawEnemyBug)
{
_bugBox = new Rectangle(-500, -500, Drawable.Art.Width, Drawable.Art.Height);
Point newPoint = randomBugPlacement();
Position = newPoint;
}
doCollisionDetection();
base.Update(gameTime);
}
开发者ID:fredriktveit,项目名称:CuteVsBugs,代码行数:26,代码来源:EnemyBugs.cs
示例15: Update
public static void Update(MouseState mouse, KeyboardState keyboard)
{
MouseMoving(mouse);
MouseClicking(mouse);
DevInput(mouse, keyboard);
}
开发者ID:Ascendzor,项目名称:Viper,代码行数:7,代码来源:Input.cs
示例16: Update
public override void Update(GameTime gameTime, Rectangle clientBounds)
{
currentFrame.X = 1;
// Move the sprite according to the direction property
position += direction;
// If the mouse moved, set the position of the sprite to the mouse position
MouseState currMouseState = Mouse.GetState();
if (currMouseState.X != prevMouseState.X ||
currMouseState.Y != prevMouseState.Y)
{
if (currMouseState.X > prevMouseState.X)
currentFrame.X = 2;
else if (currMouseState.X < prevMouseState.X)
currentFrame.X = 0;
position = new Vector2(currMouseState.X, currMouseState.Y);
}
prevMouseState = currMouseState;
//Plane Movement
if (Keyboard.GetState().IsKeyDown(Keys.Left))
currentFrame.X = 0;
if (Keyboard.GetState().IsKeyDown(Keys.Right))
currentFrame.X = 2;
// If the sprite is off the screen, put it back in play
if (position.X < 0)
position.X = 0;
if (position.Y < 0)
position.Y = 0;
if (position.X > clientBounds.Width - frameSize.X)
position.X = clientBounds.Width - frameSize.X;
if (position.Y > clientBounds.Height - frameSize.Y)
position.Y = clientBounds.Height - frameSize.Y;
base.Update(gameTime, clientBounds);
}
开发者ID:MhdAljuboori,项目名称:2DPlaneGame,代码行数:35,代码来源:UserControlledSprite.cs
示例17: Update
public void Update(Player player, 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 viewDistance = 200;
double distance = Math.Sqrt(Math.Pow(player.position.X - position.X, 2) +
Math.Pow(player.position.Y - position.Y, 2));
if (distance < viewDistance)
{
float deltaX = player.position.X - position.X;
float deltaY = player.position.Y - position.Y;
float radians = (float)Math.Atan2(deltaY, deltaX);
setRotation(radians);
float zombieSpeed = 1.5f;
float dx = (float) Math.Cos(rotation) * zombieSpeed;
float dy = (float) Math.Sin(rotation) * zombieSpeed;
position.X += dx;
position.Y += dy;
}
}
开发者ID:nfsz,项目名称:Zombie,代码行数:26,代码来源:Zombie.cs
示例18: Update
public void Update()
{
currentMouseState = Mouse.GetState();
for (int i = 0; i < MenuItems.Length; i++)
{
if (MenuRectangles[i].Intersects(new Rectangle(Mouse.GetState().X, Mouse.GetState().Y, 1, 1)))
MenuHover[i] = true;
else
MenuHover[i] = false;
}
if (lastMouseState.LeftButton == ButtonState.Pressed && currentMouseState.LeftButton == ButtonState.Released)
{
for (int i = 0; i < MenuItems.Length; i++)
{
if (MenuRectangles[i].Intersects(new Rectangle(Mouse.GetState().X, Mouse.GetState().Y, 1, 1)))
{
switch (i)
{
case 0: ClickEvent(this, new GameStateEventArgs(GameState.Lobby)); break;
case 1: ClickEvent(this, new GameStateEventArgs(GameState.Options)); break;
case 2: ClickEvent(this, new GameStateEventArgs(GameState.Credits)); break;
case 3: Process.GetCurrentProcess().Kill(); break;
}
}
}
}
lastMouseState = currentMouseState;
}
开发者ID:racegamegroep1,项目名称:RaceGame,代码行数:29,代码来源:Menu.cs
示例19: Cursor
// this constructor doesn't really do much of anything, just calls the base
// constructor, and saves the contentmanager so it can be used in
// LoadContent.
public Cursor(Game game, ContentManager content)
: base(game)
{
this.content = content;
currentMouseState = Mouse.GetState();
previousMouseState = Mouse.GetState();
}
开发者ID:holtkampw,项目名称:UH-Engine,代码行数:10,代码来源:Cursor.cs
示例20: kill
public void kill(KeyboardState kb, MouseState ms)
{
stateTimer = 0.0f;
state = State.EXIT;
this.update(kb, ms);
this.init();
}
开发者ID:rhyok,项目名称:huewgj2013,代码行数:7,代码来源:AMinigame.cs
注:本文中的Microsoft.Xna.Framework.Input.MouseState类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论