How do I measure the velocity of a swipe?

前端 未结 4 1762
北荒
北荒 2021-02-11 03:21

I\'m developing a game that will use the force of the swipe as a variable user input.

I read from the documentation that on the touchesEnded event, I can get the allTouc

4条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-11 04:02

    I've accomplished something along these lines rather simply by just comparing [touch locationInView:self] to [touch previousLocationInView:self] in touchesEnded of the Class (subclass of UIView) of the object that will be moved. This will give you a vector with location, direction & rough sense of velocity at the moment user released finger from the iPhone.

提交回复
热议问题