/// <summary> /// Checks if the given TouchEvent is on the button. /// </summary> /// <param name="e">TouchEvent to check.</param> public bool Clicked(TouchEvent e) { bool inX = e.x >= boundary.Left && e.x <= boundary.Right; bool inY = e.y >= boundary.Top && e.y <= boundary.Bottom; return inX && inY; }
private void handleTouchUp(TouchEvent touchEvent) { if (duck.Clicked (touchEvent)) { currentCharacterSprite = anim.Image; robot.Ducked = false; } if (pause.Clicked (touchEvent)) { Pause (); } if (touchEvent.x > 400) robot.StopMovingRight (); }
private void handleTouchDown(TouchEvent touchEvent) { //First handles clicks on the shoot, duck and jump buttons if (jump.Clicked (touchEvent)) { robot.Jump (); currentCharacterSprite = PictureManager.Pictures ["character_jumped"]; } else if (duck.Clicked (touchEvent) && !robot.Jumped) { currentCharacterSprite = PictureManager.Pictures ["character_ducked"]; robot.Duck (); } else if (shoot.Clicked (touchEvent) && !robot.Ducked && robot.ReadyToFire) { robot.Shoot (); } //Then handles moving if (touchEvent.x > 400) { robot.MoveRight (); } }