コード例 #1
0
    private void Update()
    {
        switch (state)
        {
        default:
        case State.WaitingToStart:
            if (TestInput())
            {
                state = State.Playing;
                birdRigidbody2D.bodyType = RigidbodyType2D.Dynamic;
                Jump();
                OnStartedPlaying?.Invoke(this, EventArgs.Empty);
            }
            break;

        case State.Playing:
            if (TestInput())
            {
                Jump();
            }

            transform.eulerAngles = new Vector3(0, 0, birdRigidbody2D.velocity.y * .15f);
            break;

        case State.Dead:
            break;
        }
    }
コード例 #2
0
ファイル: Bird.cs プロジェクト: aidanclarkescott/FlappyBird
    private void Update()
    {
        switch (state)
        {
        default:
        case State.WaitingToStart:
            if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0))
            {
                state = State.Playing;
                rigidBody.bodyType = RigidbodyType2D.Dynamic;
                Jump();
                OnStartedPlaying?.Invoke(this, EventArgs.Empty);
            }
            break;

        case State.Playing:
            if (Input.GetKeyDown(KeyCode.Space) || Input.GetMouseButtonDown(0))
            {
                Jump();
            }

            transform.eulerAngles = new Vector3(0, 0, rigidBody.velocity.y * 0.15f);
            break;

        case State.Dead:
            break;
        }
    }