示例#1
0
        /// <summary>
        /// Handle flick events
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        void flickHandler(object sender, EventArgs e)
        {
            // get the gesture that was sent to us, which will tell us
            // which object was flicked
            FlickGesture gesture = sender as FlickGesture;
            HitData      hit     = gesture.GetScreenPositionHitData();

            // get info about where the hit object was located when the gesture was
            // recognized - i.e., where on the object (in screen dimensions) did
            // the flick occur?
            Logger.Log("FLICK on " + gesture.gameObject.name + " at " + hit.Point);

            // fire event to logger to log this action
            if (this.logEvent != null)
            {
                // log the flick
                this.logEvent(this, new LogEvent(LogEvent.EventType.Action,
                                                 gesture.gameObject.name, "flick", hit.Point));
            }

            if (this.allowTouch)
            {
                // if flick/swipe was to the right, advance page
                if (gesture.ScreenFlickVector.x < 0)
                {
                    ChangePage(Constants.NEXT);
                }

                // if to the left, go back a page
                else if (gesture.ScreenFlickVector.x > 0)
                {
                    ChangePage(Constants.PREVIOUS);
                }
            }

            // trigger sound on flick as feedback?
            //if(this.allowTouch && !gesture.gameObject.tag.Contains(Constants.TAG_SIDEKICK))
            //{
            //	Logger.Log("going to play a sound for " + gesture.gameObject.name);
            //	PlaySoundAndPulse(gesture.gameObject);
            //}
        }