Ejemplo n.º 1
0
    public IEnumerator SwipeRest()
    {
        // wait before resetting the swipedirection
        yield return(new WaitForSeconds(swipeDeley));

        swipeDirection = SWIPEDIRECTION.NONE;
    }
Ejemplo n.º 2
0
 public void Touch_OnSwipe(object sender, directionMoveArgs e)
 {
     // add logic to handle the touch swipe here
     swipeDirection = e.direction;
     // the time deley before resetting the swipeDirection -1 doesn't reset the swipe
     if (swipeDeley > -1)
     {
         StartCoroutine(SwipeRest());
     }
 }
Ejemplo n.º 3
0
    public directionMoveArgs(locationMoveData moveData, bool isCardinal = true)
    {
        // assign the vectors from the passed movedate to the local vectors
        firstTouch = moveData.firstTouch;
        lastTouch  = moveData.lastTouch;

        float angle = calcAngle();

        if (isCardinal)
        {
            _direction = CardinalDirections(angle);
        }
        else
        {
            _direction = OrdinalDirections(angle);
        }
    }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        if (Input.touchCount == 1 && touchDisabled == false)//Must be 1 touch only to initiate screen swiping
        {
            Touch touch = Input.GetTouch(0);

            switch (touch.phase)
            {
            case TouchPhase.Began:
                startingTouchPosition = touch.position;
                //Debug.Log("Starting Touch Position : " + startingTouchPosition);
                break;

            case TouchPhase.Moved:
                swipeDelta = touch.position - startingTouchPosition;
                //Debug.Log("Swipe Delta : " + swipeDelta);

                OldXVal = xVal;
                xVal    = swipeDelta.x;
                Debug.Log("XVal : " + xVal);

                if (xVal > OldXVal)    //If swiping to the right
                {
                    if (currentPanelIndex != 0)
                    {
                        transform.localPosition += Vector3.right * screenSwipeSpeed * Time.deltaTime;
                    }
                    else
                    {
                        transform.localPosition = Vector3.zero;
                    }
                }
                else if (xVal < OldXVal)    //If swiping to the left
                {
                    if (currentPanelIndex != 2)
                    {
                        transform.localPosition -= Vector3.right * screenSwipeSpeed * Time.deltaTime;
                    }
                    else
                    {
                        transform.localPosition = new Vector3(-1600.0f, 0.0f, 0.0f);
                    }
                }

                totalSwipedDistance = xVal;

                break;

            case TouchPhase.Stationary:
                break;

            case TouchPhase.Ended:
                Debug.Log("Total Swipe Distance : " + totalSwipedDistance);

                if (totalSwipedDistance != 0.0f)
                {
                    if (totalSwipedDistance < (screenSwipeThreshold * -1.0f))
                    {
                        swipeDirection = SWIPEDIRECTION.LEFT;
                    }
                    else if (totalSwipedDistance > screenSwipeThreshold)
                    {
                        swipeDirection = SWIPEDIRECTION.RIGHT;
                    }
                    else
                    {
                        swipeDirection = SWIPEDIRECTION.NEUTRAL;
                    }

                    moveScreen = true;
                }

                //Debug.Log("Current Panel Index : " + currentPanelIndex);
                break;
            }
        }

        screenSnap(ref moveScreen, ref totalSwipedDistance, ref currentPanelIndex);
    }
Ejemplo n.º 5
0
    //Place your public methods here

    #endregion
    #region Private Methods
    //Place your public methods here
    private void TouchInput_OnSwipe(object sender, directionMoveArgs e)
    {
        dir = e.direction;
    }