本文整理汇总了C#中InputHelper.MouseLeftButtonPressed方法的典型用法代码示例。如果您正苦于以下问题:C# InputHelper.MouseLeftButtonPressed方法的具体用法?C# InputHelper.MouseLeftButtonPressed怎么用?C# InputHelper.MouseLeftButtonPressed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputHelper
的用法示例。
在下文中一共展示了InputHelper.MouseLeftButtonPressed方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleInput
/// <summary>
/// HandleInput for the button
/// </summary>
/// <param name="inputHelper">The inputhelper to react to input</param>
public override void HandleInput(InputHelper inputHelper)
{
wasMouseOver = isMouseOver;
//Checking whether the mouse is hovering over a button or not
if (BoundingBox.Contains((int)inputHelper.MousePosition.X, (int)inputHelper.MousePosition.Y))
isMouseOver = true;
else
isMouseOver = false;
if (!wasMouseOver && isMouseOver)
{
foreach (Sound sound in MusicPlayer.SoundEffect)
if (sound.Name == "MouseOver")
{
sound.PlaySound();
}
}
buttonWasPressed = ButtonIsPressed;
//Checking whether you are pressing the button or not
if (inputHelper.MouseLeftButtonPressed() && isMouseOver)
buttonIsPressed = true;
else
buttonIsPressed = false;
if (!buttonWasPressed && buttonIsPressed)
{
foreach (Sound sound in MusicPlayer.SoundEffect)
if (sound.Name == "MouseClick")
{
sound.PlaySound();
}
}
}
示例2: HandleInput
public override void HandleInput(InputHelper inputHelper)
{
if(inputHelper.KeyPressed(Keys.P))
{
InsaneKillerArcher.GameStateManager.SwitchTo("playingState");
}
if(MouseOver(inputHelper.MousePosition, overheadArrows) && inputHelper.MouseLeftButtonPressed()) {
InsaneKillerArcher.AssetManager.PlaySound("buy_shit");
overheadArrows.IsActive = true;
}
if (MouseOver(inputHelper.MousePosition, rollingBoulder) && inputHelper.MouseLeftButtonPressed())
{
InsaneKillerArcher.AssetManager.PlaySound("buy_shit");
rollingBoulder.IsActive = true;
}
if (MouseOver(inputHelper.MousePosition, boilingOil) && inputHelper.MouseLeftButtonPressed())
{
InsaneKillerArcher.AssetManager.PlaySound("buy_shit");
boilingOil.IsActive = true;
}
if (MouseOver(inputHelper.MousePosition, castleUpgrade) && inputHelper.MouseLeftButtonPressed())
{
InsaneKillerArcher.AssetManager.PlaySound("buy_shit");
castleUpgrade.UpgradeLevel();
}
if (MouseOver(inputHelper.MousePosition, archerUpgrade) && inputHelper.MouseLeftButtonPressed())
{
InsaneKillerArcher.AssetManager.PlaySound("buy_shit");
archerUpgrade.UpgradeLevel();
archerUpgrade.Claimed = false;
}
if (MouseOver(inputHelper.MousePosition, catapultUpgrade) && inputHelper.MouseLeftButtonPressed())
{
InsaneKillerArcher.AssetManager.PlaySound("buy_shit");
catapultUpgrade.UpgradeLevel();
}
base.HandleInput(inputHelper);
}
示例3: HandleInput
public override void HandleInput(InputHelper inputHelper)
{
base.HandleInput(inputHelper);
if (inputHelper.KeyPressed(Keys.R))
cannonColor.Color = Color.Red;
else if (inputHelper.KeyPressed(Keys.G))
cannonColor.Color = Color.Green;
else if (inputHelper.KeyPressed(Keys.B))
cannonColor.Color = Color.Blue;
double opposite = inputHelper.MousePosition.Y - cannonBarrel.GlobalPosition.Y;
double adjacent = inputHelper.MousePosition.X - cannonBarrel.GlobalPosition.X;
cannonBarrel.Angle = (float)Math.Atan2(opposite, adjacent);
if (inputHelper.MouseLeftButtonPressed() && !ball.Shooting)
ball.Shoot(inputHelper, cannonColor, cannonBarrel);
}
示例4: HandleInput
public override void HandleInput(InputHelper inputHelper)
{
pressed = inputHelper.MouseLeftButtonPressed() &&
BoundingBox.Contains((int)inputHelper.MousePosition.X, (int)inputHelper.MousePosition.Y);
}
示例5: HandleInput
public override void HandleInput(InputHelper inputHelper)
{
foreach(ClickableSpriteGameObject icon in clickableObjects.Objects)
{
if (MouseOver(inputHelper.MousePosition, icon) && inputHelper.MouseLeftButtonPressed() && icon.Clickable)
{
icon.Clicked = true;
}
}
base.HandleInput(inputHelper);
}
示例6: HandleInput
/// <summary>Check if the button is clicked.</summary>
public override void HandleInput(InputHelper inputHelper)
{
pressed = inputHelper.MouseLeftButtonPressed() && !level.Locked &&
levels_solved.BoundingBox.Contains((int)inputHelper.MousePosition.X, (int)inputHelper.MousePosition.Y);
}
示例7: HandleInput
public void HandleInput(GameTime gameTime, InputHelper inputHelper)
{
if (gameState == GameState.Playing) //Speelfase
{
blocks.HandleInput(inputHelper, i); //Het bewegen van de blokjes over het speelveld
if (inputHelper.KeyPressed(Keys.Escape))
gameState = GameState.GameOver;
}
if (gameState == GameState.Menu)
{
if (inputHelper.MouseLeftButtonPressed())
{
if (menu.PlayRect.Contains((int)inputHelper.MousePosition.X, (int)inputHelper.MousePosition.Y))
{
gameState = GameState.Playing;
}
if (menu.OptionsRect.Contains((int)inputHelper.MousePosition.X, (int)inputHelper.MousePosition.Y))
{
gameState = GameState.Options;
}
}
block1.CalculateArrayRotatingLength(4); //Hier wordt berekend hoe de blokjes moeten draaien afhankelijk van hun vorm
block2.CalculateArrayRotatingLength(4);
block3.CalculateArrayRotatingLength(4);
block4.CalculateArrayRotatingLength(4);
block5.CalculateArrayRotatingLength(4);
block6.CalculateArrayRotatingLength(4);
block7.CalculateArrayRotatingLength(4);
}
if (gameState == GameState.GameOver)
{
if (inputHelper.MouseLeftButtonPressed())
{
if (gameOver.BackRect.Contains((int)inputHelper.MousePosition.X, (int)inputHelper.MousePosition.Y))
{
score = 0;
level = 1;
levelspeed = 1;
gameState = GameState.Menu;
}
}
}
if (gameState == GameState.Options) //Optie menu
{
options.HandleInput(inputHelper);
if (inputHelper.MouseLeftButtonPressed() && options.BackRect.Contains((int)inputHelper.MousePosition.X, (int)inputHelper.MousePosition.Y)) //Het beginnen van het spel
{
block1.BlockForm = block1.CurrentBlockForm; //De bewerkte vormen moeten doorgegeven worden aan de speelfase
block2.BlockForm = block2.CurrentBlockForm;
block3.BlockForm = block3.CurrentBlockForm;
block4.BlockForm = block4.CurrentBlockForm;
block5.BlockForm = block5.CurrentBlockForm;
block6.BlockForm = block6.CurrentBlockForm;
block7.BlockForm = block7.CurrentBlockForm;
block1res.BlockForm = block1.CurrentBlockForm;
block2res.BlockForm = block2.CurrentBlockForm;
block3res.BlockForm = block3.CurrentBlockForm;
block4res.BlockForm = block4.CurrentBlockForm;
block5res.BlockForm = block5.CurrentBlockForm;
block6res.BlockForm = block6.CurrentBlockForm;
block7res.BlockForm = block7.CurrentBlockForm;
gameState = GameState.Menu;
}
}
}
示例8: HandleInput
public void HandleInput(InputHelper i)
{
if (i.MouseLeftButtonPressed())
{
if (i.MousePosition.X > (screenWidth / 2 + (-12 * block.Width)) && (i.MousePosition.Y > block.Height) && i.MousePosition.X < (screenWidth / 2 + (-8 * block.Width)) && (i.MousePosition.Y < 5 * block.Height))
{
if (block1.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-12 * block.Width))) / block.Width)] == Color.Red)
{
block1.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-12 * block.Width))) / block.Width)] = Color.Black;
block1.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-12 * block.Width))) / block.Width)].A = 0;
}
else if (block1.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-12 * block.Width))) / block.Width)] != Color.Red)
{
block1.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-12 * block.Width))) / block.Width)] = Color.Red;
}
}
if (i.MousePosition.X > (screenWidth / 2 + (-11 * block.Width)) && (i.MousePosition.Y > 5 * block.Height) && i.MousePosition.X < (screenWidth / 2 + (-9 * block.Width)) && (i.MousePosition.Y < 6 * block.Height))
{
for (int m = 0; m < 4; m++)
{
block1.CurrentBlockForm[m, 0] = Color.Black;
block1.CurrentBlockForm[m, 0].A = 0;
block1.CurrentBlockForm[m, 1] = Color.Red;
block1.CurrentBlockForm[m, 2] = Color.Black;
block1.CurrentBlockForm[m, 2].A = 0;
block1.CurrentBlockForm[m, 3] = Color.Black;
block1.CurrentBlockForm[m, 3].A = 0;
}
}
if (i.MousePosition.X > (screenWidth / 2 + (-7 * block.Width)) && (i.MousePosition.Y > block.Height) && i.MousePosition.X < (screenWidth / 2 + (-3 * block.Width)) && (i.MousePosition.Y < 5 * block.Height))
{
if (block2.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-7 * block.Width))) / block.Width)] == Color.Yellow)
{
block2.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-7 * block.Width))) / block.Width)] = Color.Black;
block2.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-7 * block.Width))) / block.Width)].A = 0;
}
else if (block2.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-7 * block.Width))) / block.Width)] != Color.Yellow)
{
block2.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-7 * block.Width))) / block.Width)] = Color.Yellow;
}
}
if (i.MousePosition.X > (screenWidth / 2 + (-6 * block.Width)) && (i.MousePosition.Y > 5 * block.Height) && i.MousePosition.X < (screenWidth / 2 + (-3 * block.Width)) && (i.MousePosition.Y < 6 * block.Height))
{
for (int m = 0; m < 4; m++)
{
block2.CurrentBlockForm[m, 0] = Color.Black;
block2.CurrentBlockForm[m, 0].A = 0;
block2.CurrentBlockForm[m, 1] = Color.Black;
block2.CurrentBlockForm[m, 1].A = 0;
block2.CurrentBlockForm[m, 2] = Color.Black;
block2.CurrentBlockForm[m, 2].A = 0;
block2.CurrentBlockForm[m, 3] = Color.Black;
block2.CurrentBlockForm[m, 3].A = 0;
}
block2.CurrentBlockForm[0, 0] = Color.Yellow;
block2.CurrentBlockForm[0, 1] = Color.Yellow;
block2.CurrentBlockForm[1, 0] = Color.Yellow;
block2.CurrentBlockForm[1, 1] = Color.Yellow;
}
if (i.MousePosition.X > (screenWidth / 2 + (-2 * block.Width)) && (i.MousePosition.Y > block.Height) && i.MousePosition.X < (screenWidth / 2 + (2 * block.Width)) && (i.MousePosition.Y < 5 * block.Height))
{
if (block3.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-2 * block.Width))) / block.Width)] == Color.Green)
{
block3.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-2 * block.Width))) / block.Width)] = Color.Black;
block3.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-2 * block.Width))) / block.Width)].A = 0;
}
else if (block3.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-2 * block.Width))) / block.Width)] != Color.Green)
{
block3.CurrentBlockForm[(int)((i.MousePosition.Y - block.Height) / block.Height),
(int)((i.MousePosition.X - (screenWidth / 2 + (-2 * block.Width))) / block.Width)] = Color.Green;
}
}
if (i.MousePosition.X > (screenWidth / 2 + (-1 * block.Width)) && (i.MousePosition.Y > 5 * block.Height) && i.MousePosition.X < (screenWidth / 2 + (1 * block.Width)) && (i.MousePosition.Y < 6 * block.Height))
{
for (int m = 0; m < 4; m++)
{
block3.CurrentBlockForm[m, 0] = Color.Black;
block3.CurrentBlockForm[m, 0].A = 0;
//.........这里部分代码省略.........