コード例 #1
0
        public override void Tap(SKPointI point)
        {
            base.Tap(point);

            if (ShowButtons)
            {
                if (playButton.HitTest(point))
                {
                    PlayTapped?.Invoke(this, EventArgs.Empty);
                }
                else if (scoresButton.HitTest(point))
                {
                    ScoresTapped?.Invoke(this, EventArgs.Empty);
                }
            }

            // if we aren't scrolling, then it is game over
            if (!scrolling)
            {
                return;
            }

            // start the flapping if this is the first time tapping
            if (!interactiveMode)
            {
                interactiveMode = true;

                // take the current bob and add it to the position
                // before turing off bobbing
                playerPos.Y          += bobbingBird.BobOffset;
                bobbingBird.BobOffset = 0f;

                tutorial.Hide();
            }

            // flap those wings!
            bobbingBird.StartFlapping();

            // apply flap force
            if (playerPos.Y > 0)
            {
                // a flap cancels all downward momentum
                speed             = BobbingBird.FlapStrength;
                acceleration      = BobbingBird.Gravity;
                angleChange       = BobbingBird.InitialRotationAcceleration;
                angleAcceleration = BobbingBird.RotationAcceleration;
            }
        }
コード例 #2
0
ファイル: WelcomeScreen.cs プロジェクト: tnsrc/FlappyBird
        public override void Tap(SKPointI point)
        {
            base.Tap(point);

            if (rateButton.HitTest(point))
            {
                RatingsTapped?.Invoke(this, EventArgs.Empty);
            }
            else if (playButton.HitTest(point))
            {
                PlayTapped?.Invoke(this, EventArgs.Empty);
            }
            else if (scoresButton.HitTest(point))
            {
                ScoresTapped?.Invoke(this, EventArgs.Empty);
            }
        }