开发者

How to rotate an image using touch

Can anyone tell me that how can i rotate a view with respect to touch given by user....

开发者_运维技巧

I mean i want to make similar appearance like the old telephones were(press and rotate to dial...)...

How to rotate an image using touch

I know very well how to rotate but was unable to rotate according to this situation.....


You need a view with only the dial image.

This view has a center C(x,y)
First, the view will be touched at coordinate T0(x,y)

if the x and y is within the circle do the tracking:
    Then the finger will move to coordinate Tn(x,y) 
    Find the angle made up by Tn(x,y) C(x,y) T0(x,y)  //(See below for a reference)
    and do the rotation using that angle as you already know ;)
else
   do nothing since the touch is not in the dial 

Ref: How to calculate an angle from three points


Calculate angle between the starting touch and the center of the dial (atan2f(y - yc, x - xc)), and use that as the basis angle to determine the rotation required for each subsequent touch event.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜