开发者

iphone touch coordinates

Is there a way to get the coordinates off all touches currently on the display at any given time without having to keep track of all of the touchesBegan, touchesMoved, and touchesEnded. Because as far as I can tell getting the coordinates within any one 开发者_运维问答of these functions by doing:

NSSet *allTouches = [event allTouches];
UITouch *touch = [[allTouches allObjects] objectAtIndex:0];
...

only reports the touches that move end or start. I need to the the cords off all fingers not just the fingers who's locations have changed.


There is no built in way to do this.

The way I've done it in the past is to keep a list of coordinates, add to that in touchesBegan, update those based on the the closest touch in proximity to the points in that list in touchesMoved, and remove based on the nearest proximity in touchesEnded and Cancelled.

All in all its not too bad, you can also attach state information to these updates to give you a system to poll and get a list of all current touches and their current state.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜