private void CreateSwipe() { swipe = new SwipeGestureRecognizer(); swipe.Direction = SwipeGestureRecognizerDirection.Right; swipe.StateUpdated += SwipeHandle; FingersScript.Instance.AddGesture(swipe); }
private void Start() { playerBody = GetComponent <Rigidbody2D>(); TapGesture = new TapGestureRecognizer(); TapGesture.StateUpdated += JumpTap_StateUpdated; TapGesture.ClearTrackedTouchesOnEndOrFail = true; // require fast taps TapGesture.ThresholdSeconds = JumpThresholdSeconds; // allow a little more slide than a normal tap TapGesture.ThresholdUnits = JumpThresholdUnits; PanGesture = new PanGestureRecognizer(); PanGesture.StateUpdated += MovePan_StateUpdated; PanGesture.ThresholdUnits = 0.35f; // require a little more slide before panning starts // jump up and move sideways is allowed PanGesture.AllowSimultaneousExecution(TapGesture); // swipe down requires no other gestures to be executing SwipeGesture = new SwipeGestureRecognizer { Direction = SwipeGestureRecognizerDirection.Down }; SwipeGesture.StateUpdated += SwipeDown_StateUpdated; SwipeGesture.AllowSimultaneousExecution(PanGesture); FingersScript.Instance.AddGesture(TapGesture); FingersScript.Instance.AddGesture(PanGesture); FingersScript.Instance.AddGesture(SwipeGesture); }
private void CreateSwipeGesture() { swipeGesture = new SwipeGestureRecognizer(); swipeGesture.Direction = SwipeGestureRecognizerDirection.Any; swipeGesture.StateUpdated += SwipeGestureCallback; swipeGesture.DirectionThreshold = 1.0f; // allow a swipe, regardless of slope FingersScript.Instance.AddGesture(swipeGesture); }
private void Start() { SwipeGestureRecognizer swipe = new SwipeGestureRecognizer(); swipe.Updated += Swipe_Updated; swipe.DirectionThreshold = 0; FingersScript.Instance.AddGesture(swipe); }
private void Start() { swipe = new SwipeGestureRecognizer(); swipe.StateUpdated += Swipe_Updated; swipe.DirectionThreshold = 0; swipe.MinimumNumberOfTouchesToTrack = swipe.MaximumNumberOfTouchesToTrack = SwipeTouchCount; FingersScript.Instance.AddGesture(swipe); TapGestureRecognizer tap = new TapGestureRecognizer(); tap.StateUpdated += Tap_Updated; FingersScript.Instance.AddGesture(tap); }
private void Swipe_Updated(GestureRecognizer gesture, ICollection <GestureTouch> touches) { SwipeGestureRecognizer swipe = gesture as SwipeGestureRecognizer; if (swipe.State == GestureRecognizerState.Began) { float angle = Mathf.Atan2(-swipe.DistanceY, swipe.DistanceX) * Mathf.Rad2Deg; SwipeParticleSystem.transform.rotation = Quaternion.Euler(angle, 90.0f, 0.0f); Vector3 pos = Camera.main.ScreenToWorldPoint(new Vector3(gesture.StartFocusX, gesture.StartFocusY, 0.0f)); pos.z = 0.0f; SwipeParticleSystem.transform.position = pos; SwipeParticleSystem.Play(); } Debug.LogFormat("Swipe state: {0}", gesture.State); }
private void Swipe_Updated(DigitalRubyShared.GestureRecognizer gesture) { Debug.LogFormat("Swipe state: {0}", gesture.State); SwipeGestureRecognizer swipe = gesture as SwipeGestureRecognizer; if (swipe.State == GestureRecognizerState.Ended) { float angle = Mathf.Atan2(-swipe.DistanceY, swipe.DistanceX) * Mathf.Rad2Deg; SwipeParticleSystem.transform.rotation = Quaternion.Euler(angle, 90.0f, 0.0f); Vector3 pos = Camera.main.ScreenToWorldPoint(new Vector3(gesture.StartFocusX, gesture.StartFocusY, 0.0f)); pos.z = 0.0f; SwipeParticleSystem.transform.position = pos; SwipeParticleSystem.Play(); Debug.LogFormat("Swipe dir: {0}", swipe.EndDirection); } }
private void Swipe_Updated(GestureRecognizer gesture) { Debug.LogFormat("Swipe state: {0}", gesture.State); SwipeGestureRecognizer swipe = gesture as SwipeGestureRecognizer; if (swipe.State == GestureRecognizerState.Ended) { float angle = Mathf.Atan2(-swipe.DistanceY, swipe.DistanceX) * Mathf.Rad2Deg; SwipeParticleSystem.transform.rotation = Quaternion.Euler(angle, 90.0f, 0.0f); Vector3 pos = Camera.main.ScreenToWorldPoint(new Vector3(gesture.StartFocusX, gesture.StartFocusY, 0.0f)); pos.z = 0.0f; SwipeParticleSystem.transform.position = pos; SwipeParticleSystem.Play(); if (ResetStateOnEnd) { // allow the gesture to restart, using existing touches even if they are not lifted gesture.BeginGestureRestart(); } } }
//旋转效果不是很好,需要滑动完成去转动 private void CreateSwipeGesture() { swipeGesture = new SwipeGestureRecognizer(); swipeGesture.StateUpdated += SwipeGestureCallBack; FingersScript.Instance.AddGesture(swipeGesture); }
private void CreateSwipeGesture() { swipeGesture = new SwipeGestureRecognizer(); swipeGesture.Direction = SwipeGestureRecognizerDirection.Any; swipeGesture.Updated += SwipeGestureCallback; swipeGesture.DirectionThreshold = 1.0f; // allow a swipe, regardless of slope FingerScript.AddGesture(swipeGesture); }