Esempio n. 1
0
        // Handle pan start events
        private void panStartedHandler(object sender, EventArgs e)
        {
            // get the gesture that was sent to us, which will tell us which object was pressed
            PanGesture gesture = sender as PanGesture;

            // get info about where the hit object was located when the gesture was recognized
            ITouchHit hit;

            if (gesture.GetTargetHitResult(out hit))
            {
                // want the info as a 2D point
                ITouchHit2D hit2d = (ITouchHit2D)hit;
                Debug.Log("PAN STARTED on " + gesture.gameObject.name + " at " + hit2d.Point);
            }
        }
Esempio n. 2
0
        // Handle pan / drag events
        private void pannedHandler(object sender, EventArgs e)
        {
            // get the gesture that was sent to us, which will tell us which object was pressed
            PanGesture gesture = sender as PanGesture;

            // get info about where the hit object was located when the gesture was recognized
            ITouchHit hit;

            if (gesture.GetTargetHitResult(out hit))
            {
                // want the info as a 2D point
                ITouchHit2D hit2d = (ITouchHit2D)hit;
                Debug.Log("PAN on " + gesture.gameObject.name + " at " + hit2d.Point);

                // move the object with the drag
                gesture.gameObject.transform.position = new Vector3(hit2d.Point.x, hit2d.Point.y, -2);

                // TODO make sure the object being dragged can't fly off the screen
            }
        }