本文整理汇总了C#中Microsoft.Xna.Framework.Input.KeyboardState.ClickPress方法的典型用法代码示例。如果您正苦于以下问题:C# KeyboardState.ClickPress方法的具体用法?C# KeyboardState.ClickPress怎么用?C# KeyboardState.ClickPress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Input.KeyboardState
的用法示例。
在下文中一共展示了KeyboardState.ClickPress方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public override void Update(GameTime gameTime)
{
timeSinceSpawn += gameTime.ElapsedGameTime;
prevMouseState = mouseState;
mouseState = Mouse.GetState();
prevKBState = KBState;
KBState = Keyboard.GetState();
if (KBState.ClickPress(prevKBState,Keys.L))
{
}
//
// if (mouseState.LeftButton == ButtonState.Pressed &&
// prevMouseState.LeftButton == ButtonState.Released)
// {
// if (KBState.ClickPress(lastKeyboardState,Keys.LeftShift))
// {
// curveX.Keys.Clear();
// curveY.Keys.Clear();
// span = -1f;
// }
// span++;
// curveX.Keys.Add(new CurveKey(span,mouseState.X));
// curveY.Keys.Add(new CurveKey(span,mouseState.Y));
// InitializePoints();
// }
Pos.X = curveX.Evaluate((float) timeSinceSpawn.TotalSeconds%span);
Pos.Y = curveY.Evaluate((float) timeSinceSpawn.TotalSeconds%span);
base.Update(gameTime);
}
示例2: Update
public override void Update(GameTime gameTime)
{
someVect = new Vector2();
prevKeyboard = keyboard;
keyboard = Keyboard.GetState();
distance = Vector2.Distance(pathNodes[currentNodeIndex], Pos);
if (keyboard.ClickPress(prevKeyboard,Keys.Space) || distance < 60)
{
++currentNodeIndex;
currentNodeIndex %= pathNodes.Count;
}
// MouseState mouse = Mouse.GetState();
// pathNodes[4] = new Vector2(mouse.X,mouse.Y);
angleToTarget = MathHelper.ToDegrees((float) (Math.Atan2(
pathNodes[currentNodeIndex].Y - Pos.Y,
pathNodes[currentNodeIndex].X - Pos.X)));
angleToTarget = angleToTarget-AngleInDeg;
angleToTarget -= 90f;
if (angleToTarget < -180f)
{
angleToTarget += 360f;
}
else if (angleToTarget > 180f)
{
angleToTarget -= 360f;
}
if (angleToTarget < 0f)
{
AngleInDeg -= 1f;
}
else if (angleToTarget > 0f)
{
AngleInDeg += 1f;
}
// sqrtVelY = 1 - (0.5 * Math.Pow(Velocity.Y / 1000, 2));
// sqrtVelX = 1 - (0.5 * Math.Pow(Velocity.X / 1000, 2));
// var xCircle = Velocity.X * Math.Sqrt(sqrtVelY) * timeInSeconds;
// var yCircle = Velocity.Y * Math.Sqrt(sqrtVelX) * timeInSeconds;
// Pos.X += (float)(xCircle);
// Pos.Y += (float)(yCircle);
var angle = AngleToVector(AngleInRad);
Pos += angle*3;
base.Update(gameTime);
}
示例3: Update
public override void Update(GameTime gameTime)
{
prevKeyboard = keyboard;
keyboard = Keyboard.GetState();
if (keyboard.IsKeyDown(Keys.Left))
{
AngleInDeg = AngleInDeg + 1;
}
else if (keyboard.IsKeyDown(Keys.Right))
{
AngleInDeg = AngleInDeg - 1;
}
if (keyboard.ClickPress(prevKeyboard,Keys.H))
{
test = !test;
}
UtilityMethods.MoveVector2WASD(ref Pos, ref BoundingRect);
currentCellsOccupied.Clear();
currentCellsOccupiedString = "";
grid = new List<int>[GridWide, GridHigh];
rect = BoundingRect;
for (int i = (int)Math.Floor((double)(rect.Top * 2) / framesize); i < (int)Math.Ceiling((double)(rect.Bottom * 2) / framesize); i++)
{
for (int j = (int)Math.Floor((double)(rect.Left * 2) / framesize); j < (int)Math.Ceiling((double)(rect.Right * 2) / framesize); j++)
{
if (j >= 0 && j < GridWide && i >= 0 && i < GridHigh)
{
if (grid[j, i] == null)
{
grid[j, i] = new List<int>();
}
grid[j, i].Add(1);
// currentCellsOccupied.Add(new[]{j,i});
// currentCellsOccupiedString += "(" + j + "," + i + "), ";
}
}
}
rect = new Rectangle((int)(WidthOfGame / 4 - Origin.X), (int)(HeightOfGame / 4 - Origin.Y), Frames[0].Width, Frames[0].Height);
for (int i = (int)Math.Floor((double)(rect.Top * 2) / framesize); i < (int)Math.Ceiling((double)(rect.Bottom * 2) / framesize); i++)
{
for (int j = (int)Math.Floor((double)(rect.Left * 2) / framesize); j < (int)Math.Ceiling((double)(rect.Right * 2) / framesize); j++)
{
if (j >= 0 && j < GridWide && i >= 0 && i < GridHigh)
{
if (grid[j, i] == null)
{
grid[j, i] = new List<int>();
}
grid[j, i].Add(2);
}
currentCellsOccupiedString += "(" + j + "," + i + "), ";
currentCellsOccupied.Add(new[] { j, i });
}
}
someVect = new Vector2();
isColliding = false;
for (int i = 0; i < GridHigh; i++)
{
for (int j = 0; j < GridWide; j++)
{
if (grid[j, i] == null)
{
grid[j, i] = new List<int>();
}
if (grid[j, i].Count < 2)
{
continue;
}
var mat1 = UtilityMethods.Get2DTransformationMatrix(-Origin, AngleInRad, 2f, Pos);
var mat2 = UtilityMethods.Get2DTransformationMatrix(-Origin, null, 2f,
new Vector2(WidthOfGame / 2, HeightOfGame / 2));
// Matrix mat1 =
// Matrix.CreateTranslation(new Vector3(-Origin, 0.0f)) *
// Matrix.CreateScale(2f) *// would go here
// Matrix.CreateRotationZ(AngleInRad) *
// Matrix.CreateTranslation(new Vector3(Pos, 0.0f));
//
// Matrix mat2 =
// Matrix.CreateTranslation(new Vector3(-Origin, 0.0f)) *
// Matrix.CreateScale(2f) *// would go here
//// Matrix.CreateRotationZ(AngleInRad) *
// Matrix.CreateTranslation(new Vector3(new Vector2(WidthOfGame / 2, HeightOfGame / 2), 0.0f));
isColliding = UtilityMethods.TexturesCollide(ColorArrays[0], mat1, ColorArrays[0], mat2);
// isColliding = IntersectPixels(mat1, 20, 25, ColorArrays[0], mat2, 20, 25, ColorArrays[0]);
// isColliding = someVect != new Vector2(-1, -1);
}
}
base.Update(gameTime);
}
示例4: Update
public override void Update(GameTime gameTime)
{
timeSinceSpawn += gameTime.ElapsedGameTime;
// CheckGamePadInput();
// CheckKeyboardInput();
prevMouseState = mouseState;
mouseState = Mouse.GetState();
prevKBState = KBState;
KBState = Keyboard.GetState();
if (KBState.ClickPress(prevKBState, Keys.L))
{
GetCurve("X.xml", out curveX);
GetCurve("Y.xml", out curveY);
timeSinceSpawn = new TimeSpan(0, 0, 0);
var lastOrDefault = curveX.Keys.LastOrDefault();
span = lastOrDefault != null ? lastOrDefault.Position : 1f;
lastOrDefault = curveY.Keys.LastOrDefault();
if (lastOrDefault != null && lastOrDefault.Position > span)
{
span = lastOrDefault.Position;
}
InitializeTransform();
InitializeEffect();
InitializePoints();
InitializeLineStrip();
}
//
// if (mouseState.LeftButton == ButtonState.Pressed &&
// prevMouseState.LeftButton == ButtonState.Released)
// {
// if (KBState.ClickPress(lastKeyboardState,Keys.LeftShift))
// {
// curveX.Keys.Clear();
// curveY.Keys.Clear();
// span = -1f;
// }
// span++;
// curveX.Keys.Add(new CurveKey(span,mouseState.X));
// curveY.Keys.Add(new CurveKey(span,mouseState.Y));
// InitializePoints();
// }
Pos.X = curveX.Evaluate((float)timeSinceSpawn.TotalSeconds % span);
Pos.Y = curveY.Evaluate((float)timeSinceSpawn.TotalSeconds % span);
base.Update(gameTime);
}
示例5: HandleInput
private void HandleInput(GameTime gameTime)
{
LastKBState = CurrentKBState;
CurrentKBState = Keyboard.GetState();
timeInSeconds = (float)gameTime.ElapsedGameTime.TotalSeconds;
//buffMultiplierX = 5;// (Velocity.X / maxVelocity * 100) + 1;
//if (buffMultiplierX < 1) buffMultiplierX = 1;
if ((CurrentKBState.IsKeyDown(Keys.Left) ||
CurrentKBState.IsKeyDown(Keys.A))&& Velocity.X >= -maxVelocity)
{
Velocity.X -= (Velocity.X > 0 ? increment*buffMultiplier : increment)*timeInSeconds;
}
else if ((CurrentKBState.IsKeyDown(Keys.Right) ||
CurrentKBState.IsKeyDown(Keys.D))&& Velocity.X <= maxVelocity)
{
Velocity.X += (Velocity.X < 0 ? increment*buffMultiplier : increment)*timeInSeconds;
}
else if (Velocity.X > 0)
{
Velocity.X -= increment*timeInSeconds;
}
else if (Velocity.X < 0)
{
Velocity.X += increment*timeInSeconds;
}
//buffMultiplierY = (Velocity.Y / maxVelocity*100) + 1;
//if (buffMultiplierY < 1) buffMultiplierY = 1;
if ((CurrentKBState.IsKeyDown(Keys.Up) ||
CurrentKBState.IsKeyDown(Keys.W)) && Velocity.Y >= -maxVelocity)
{
Velocity.Y -= (Velocity.Y > 0 ? increment*buffMultiplier : increment)*timeInSeconds;
}
else if ((CurrentKBState.IsKeyDown(Keys.Down) ||
CurrentKBState.IsKeyDown(Keys.S)) && Velocity.Y <= maxVelocity)
{
Velocity.Y += (Velocity.Y < 0 ? increment*buffMultiplier : increment)*timeInSeconds;
}
else if (Velocity.Y > 0)
{
//if (Velocity.Y < 1) Velocity.Y = 1
Velocity.Y -= increment * timeInSeconds;
}
else if (Velocity.Y < 0)
{
Velocity.Y += increment * timeInSeconds;
}
// if (kbState.IsKeyDown(Keys.E))
// {
// mode = (mode + 1) % 3;
// }
// if (kbState.IsKeyDown(Keys.SPACE))
// {
// fireGun();
//
// }
// if (kbState.IsKeyDown(Keys.L))
// {
// (FP.world.create(EnemyShip) as EnemyShip).setInit();
// }
//
//DEBUG
if (CurrentKBState.ClickPress(LastKBState,Keys.D1))
{
maxVelocity -= 10;
}
if (CurrentKBState.ClickPress(LastKBState,Keys.D2))
{
maxVelocity += 10;
}
if (CurrentKBState.ClickPress(LastKBState,Keys.D3))
{
increment-=100;
}
if (CurrentKBState.ClickPress(LastKBState,Keys.D4))
{
increment+=100;
}
if (CurrentKBState.ClickPress(LastKBState,Keys.D5))
{
buffMultiplier -= 1;
}
if (CurrentKBState.ClickPress(LastKBState,Keys.D6))
{
buffMultiplier += 1;
}
}