예제 #1
0
    void Update()
    {
        if (inMotion)
        {
            coroutine.MoveNext();
        }
        touchOutput = swipeController.Tap();

        if (touchOutput[0] == 0)
        {
            transform.position = transform.position += transform.right * -speed * Time.deltaTime;
        }

        if (touchOutput[1] == 0)
        {
            transform.position = transform.position += transform.right * speed * Time.deltaTime;
        }

        // Detect space key press and allow jump if collision with ground is true

        //if (Input.GetKey(KeyCode.D) && Input.GetKeyDown(KeyCode.Space) && grounded)
        //{
        //    Debug.Log("pressed");
        //    grounded = false;
        //    myBody.velocity += jumpVelocity * Vector2.up;
        //    transform.position = transform.position += transform.right * speed * Time.deltaTime;

        //}

        if (1 == touchOutput[1] && grounded)
        {
            grounded = false;

            /*
             * Transform Vector2(x,y)
             */
            StartCoroutine(coroutine);
        }

        //if (Input.GetKey("space") && grounded == false)
        //{
        //    doubleJump = false;
        //    myBody.velocity += jumpVelocity * Vector2.up;
        //}
    }