开发者

How to make a character following your finger in Cocoa?

开发者 https://www.devze.com 2023-01-22 21:37 出处:网络
It was kind simple in other OS. I just got mouse movement x and y and redraw my character, however I do not see mouse event in Cocoa. COuld somebody point on a开发者_StackOverflow社区 code samples?Wha

It was kind simple in other OS. I just got mouse movement x and y and redraw my character, however I do not see mouse event in Cocoa. COuld somebody point on a开发者_StackOverflow社区 code samples?


What you want is a UIPanGestureRecognizer (see the WWDC10 videos gesture recognizer videos). With the Pan gesture recognizer, when the user press and holds their finger, then begins to drag it, you can get direction of the drag, redraw as they drag.

Get the coordinates in the frame where they were touched, use that as a the point by which you animate your view, so the view always moves where the user started dragging from.

0

精彩评论

暂无评论...
验证码 换一张
取 消