本文整理汇总了C#中Microsoft.IsKeyDown方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.IsKeyDown方法的具体用法?C# Microsoft.IsKeyDown怎么用?C# Microsoft.IsKeyDown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft
的用法示例。
在下文中一共展示了Microsoft.IsKeyDown方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public override void Update(GameTime gametime, Microsoft.Xna.Framework.Input.KeyboardState kbstate, Microsoft.Xna.Framework.Input.MouseState moustate)
{
this._Model.Update(gametime, kbstate, moustate);
if(kbstate.IsKeyDown(Keys.A))
{
//this._Model.PlayClip(FLY_IDLE);
}
else if (kbstate.IsKeyDown(Keys.S))
{
this._Model.PlayClip(GROUND_IDLE, true);
}
}
示例2: Control
public override bool Control( GameEntity control, TimeSpan gameTime, Microsoft.Xna.Framework.Input.KeyboardState keyState )
{
if ( control == Owner && Owner.IsAlive && keyState.IsKeyDown( Owner.Keys.KeyShoot ) && ( lastShot == TimeSpan.Zero || ( gameTime - lastShot ).TotalMilliseconds > speed ) )
{
Owner.Shoot( gameTime );
lastShot = gameTime;
}
return base.Control( control, gameTime, keyState );
}
示例3: Update
public void Update(InGame world, Microsoft.Xna.Framework.Input.KeyboardState ks)
{
//Checking for input.
if (ks.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left) && (ks.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right)))
{
}
else if ((ks.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left)) && (PositionX > 0))
{
PositionX -= Speed;
//The paddle can't go off the left side of the screen.
if (PositionX < 0)
PositionX = 0;
}
else if ((ks.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right))&& (PositionX < Breakout.StageWidth - Width))
{
PositionX += Speed;
//The paddle can't go beyond the right side of the stage.
if (PositionX > Breakout.StageWidth - Width)
//If we try, We are set next to the edge.
PositionX = Breakout.StageWidth - Width;
}
}
示例4: HandleInput
public void HandleInput(Microsoft.Xna.Framework.Input.KeyboardState keyboardState, Raquette _Raquette)
{
if (keyboardState.IsKeyDown(Keys.Space) && !_Launched && _StartTimer <= 0.0f)
{
_Launched = true;
}
if (keyboardState.IsKeyDown(Keys.Space) && _Stuck)
{
_Stuck = false;
PositionY = _Raquette.Position.Y - 20;
Speed = 0.5f;
}
//Si la balle est stuck tant que la balle reste dans le cadre on la fait bouger avec la raquette
if (((keyboardState.IsKeyDown(Keys.Left) && (Position.X > _Viewport.X)) || (keyboardState.IsKeyDown(Keys.Right) && (Position.X + Texture.Width) < (_Viewport.Width + _Viewport.X) )) && _Stuck)
{
PositionX = _Raquette.PositionX + _DistanceFromRaquette;
}
}
示例5: Update
public override void Update(Microsoft.Xna.Framework.GameTime gameTime, Microsoft.Xna.Framework.Input.KeyboardState keyboard, Microsoft.Xna.Framework.Input.MouseState mouse)
{
if (findingNetwork)
{
if (introTime > 8.1f) introTime -= (float)gameTime.ElapsedGameTime.TotalSeconds * 4;
networkTime -= (float)gameTime.ElapsedGameTime.TotalSeconds;
if (networkTime < lastNetTime)
{
lastNetTime--;
Network.FindServer();
if (Network.IsConnected)
Login();
}
if (networkTime <= 0)
{
findingNetwork = false;
lastNetTime = 10;
netFailString = "No Network Found.";
}
}
else
{
introTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
if (networkTime < 10)
networkTime += (float)gameTime.ElapsedGameTime.TotalSeconds * 2;
}
if (introTime < 0 && introTime > -1)
MobileFortressClient.Game.Exit();
if (introTime > 8)
{
Manager.Update(gameTime,mouse);
if (keyboard.IsKeyDown(Keys.Enter))
{
if (!loginMenuScroll)
loginButton.DoClick();
else
loginConfirmButton.DoClick();
}
}
else
{
if (keyboard.IsKeyDown(Keys.Escape) || keyboard.IsKeyDown(Keys.Enter))
introTime = 8;
}
Viewport viewport = MobileFortressClient.Game.GraphicsDevice.Viewport;
if (loginMenuScroll)
{
Color disabledColor = new Color(96, 64, 64);
loginButton.canClick = false;
loginButton.color = Color.Lerp(loginButton.color, disabledColor, 0.3f);
optionsButton.canClick = false;
optionsButton.color = Color.Lerp(optionsButton.color, disabledColor, 0.3f);
exitButton.canClick = false;
exitButton.color = Color.Lerp(exitButton.color, disabledColor, 0.3f);
if (scrolledAmt < loginMenu.Height)
{
foreach (UIElement element in Manager.Elements)
{
element.dimensions.Y -= 4;
}
scrolledAmt += 4;
}
loginDimensions.Y = viewport.Height - scrolledAmt;
}
else
{
loginButton.canClick = true;
loginButton.color = Color.Lerp(loginButton.color, Color.LightGray, 0.3f);
optionsButton.canClick = true;
optionsButton.color = Color.Lerp(optionsButton.color, Color.LightGray, 0.3f);
exitButton.canClick = true;
exitButton.color = Color.Lerp(exitButton.color, Color.LightGray, 0.3f);
if (scrolledAmt > 0)
{
foreach (UIElement element in Manager.Elements)
{
element.dimensions.Y += 4;
}
scrolledAmt -= 4;
}
loginDimensions.Y = viewport.Height - scrolledAmt;
}
}
示例6: OnGameBaseKeyPress
private void OnGameBaseKeyPress(Keys[] keys, Microsoft.Xna.Framework.Input.KeyboardState state)
{
if (state.IsKeyDown(Keys.F12))
{
IsGameRunning = false;
Exit();
}
else if (keys.Length > 0)
{
OnKeyPress(keys, state);
}
}
示例7: shouldSnapRotation
internal static bool shouldSnapRotation(Microsoft.Xna.Framework.Input.KeyboardState kstate)
{
return !kstate.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl);
}
示例8: shouldSnapPosition
internal static bool shouldSnapPosition(Microsoft.Xna.Framework.Input.KeyboardState kstate)
{
//This patch enables free positioning (ignore grid) when left control is held
return (Constants.Instance.SnapToGrid && !kstate.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftControl));
}
示例9: HandleInput
public void HandleInput(Microsoft.Xna.Framework.Input.KeyboardState keyboardState, ContentManager content)
{
if (keyboardState.IsKeyDown(Keys.Left) && Position.X > _Viewport.X)
{
PositionX -= Speed * ElapsedTime;
}
if (keyboardState.IsKeyDown(Keys.Right) && (Position.X + (Texture.Width * _SizeScale)) < _Viewport.Width + _Viewport.X)
{
PositionX += Speed * ElapsedTime;
}
BulletsTimer += ElapsedTime;
if (_ListeBonus.ContainsKey(BonusType.Bullets) && keyboardState.IsKeyDown(Keys.A) && BulletsTimer >= 200.0f)
{
BulletsTimer = 0;
Bullets BulletGauche = new Bullets(BulletsSide.Left);
Bullets BulletDroite = new Bullets(BulletsSide.Right);
_ListeBullets.Add(BulletGauche);
_ListeBullets.Add(BulletDroite);
BulletGauche.LoadContent(content, "Bullets");
BulletDroite.LoadContent(content, "Bullets");
BulletGauche.Initialize(_Viewport, this);
BulletDroite.Initialize(_Viewport, this);
}
}