本文整理汇总了C#中TouchCollection.Any方法的典型用法代码示例。如果您正苦于以下问题:C# TouchCollection.Any方法的具体用法?C# TouchCollection.Any怎么用?C# TouchCollection.Any使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TouchCollection
的用法示例。
在下文中一共展示了TouchCollection.Any方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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)
{
base.Update (gameTime);
if (adView.BannerLoaded)
{
adView.Hidden = false;
} else
{
adView.Hidden = true;
}
if (!(State == GameState.Paused)) {
// save previous state of keyboard and gamepad to determine key/button presses
previousGamePadState = currentGamePadState;
previousKeyboardState = currentKeyboardState;
previousTouches = currentTouches;
// read current state of keyboard and gamepad and store it
currentGamePadState = GamePad.GetState (PlayerIndex.One);
currentKeyboardState = Keyboard.GetState ();
currentTouches = TouchPanel.GetState ();
// update player
var shouldSwim = currentTouches.Any () || currentKeyboardState.IsKeyDown (Keys.Space) || currentGamePadState.IsButtonDown (Buttons.A);
if (shouldSwim && State == GameState.Menu) {
State = GameState.Playing;
} else if (shouldSwim && State == GameState.Score) {
shouldSwim = false;
}
// update player
if (deadFromHook) {
player.Update (true);
foreach (var hook in hooks) {
if (hook.Collides (player.Rectangle)) {
hook.Update (deadFromHook);
}
}
} else if (deadFromEnergy) {
player.Update (true);
} else if (deadFromFloor) {
player.Update (true);
} else {
player.Update (gameTime, shouldSwim, graphics.GraphicsDevice.Viewport.Height - (int)(adView.Frame.Height *3), State == GameState.Menu);
}
if (State != GameState.Score) {
}
if (State == GameState.Playing) {
UpdateHooks (gameTime);
UpdateWorms (gameTime);
UpdateCorals (gameTime);
UpdateCollision ();
if (score == 0 && !hasPlayedSound) {
hasPlayedSound = true;
bubbleSound.Play ();
}
else if (score != 0 && score % 3 == 0 && playSound) {
playSound = false;
bubbleSound.Play ();
} else {
if (score % 3 != 0) {
playSound = true;
}
bubbleSound.Dispose ();
}
} else if (State == GameState.Score) {
UpdateGameOver (gameTime);
if (gameOverAnimationDuration <= gameOverTimer && Toggled ()) {
Reset ();
}
}
}
}
示例2: HandleInput
public override void HandleInput(GameTime gameTime, InputState input)
{
//// get all of our input states
keyboardState = Keyboard.GetState();
//gamePadState = GamePad.GetState(PlayerIndex.One);
touchState = TouchPanel.GetState();
accelerometerState = Accelerometer.GetState();
if (maze.player.IsAlive == false)
{
if (keyboardState.IsKeyDown(Keys.Space) || gamePadState.IsButtonDown(Buttons.A) || touchState.Any() == true)
{
maze.StartRoom().StartNewLife(ScreenManager.GraphicsDevice);
}
}
// Exit the game when back is pressed.
///// if (gamePadState.Buttons.Back == ButtonState.Pressed)
////// Exit();
bool continuePressed = keyboardState.IsKeyDown(Keys.Space) || gamePadState.IsButtonDown(Buttons.A) || touchState.Any();
wasContinuePressed = continuePressed;
}