Author Topic: Detect swipe velocity and start/end  (Read 9336 times)

ronronmx

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Detect swipe velocity and start/end
« on: September 22, 2012, 01:45:28 AM »
Hi guys, i'm new here, and also a new user of NGUI, and I have a few questions...

I have a DetectInput() class which checks for thumb slides. I get the start Vector2 of the slide when calling 'TouchPhase.Began', and then check for the position of the slide in 'TouchPhase.Moved', and if 'slideEnd - slideStart > 200' I then do something.

Does NGUI have a built-in way to check for TouchPhases? I can get the position of the swipe by using 'OnDrag(Vector2 delta)', but how can I check for the delta position when the swipe starts, for example in 'OnPress(bool isPressed)' since it doesn't have a Vector2 parameter?

I don't want to start mixing my touch detection code with NGUI's, so if I can do everything the same with NGUI then I'd rather do that.

Thanks for your time!
Stephane

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Detect swipe velocity and start/end
« Reply #1 on: September 22, 2012, 11:27:25 AM »
UICamera.currentTouch.pos tells you the current position of the touch action inside an NGUI event callback such as OnDrag. UICamera.currentTouch.totalDelta tells you the delta since OnPress(true).

ronronmx

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: Detect swipe velocity and start/end
« Reply #2 on: September 25, 2012, 01:05:57 PM »
UICamera.currentTouch.pos tells you the current position of the touch action inside an NGUI event callback such as OnDrag. UICamera.currentTouch.totalDelta tells you the delta since OnPress(true).

Got it, thanks!