[SOLVED] Help with rotating dial

Hi,

I'm trying to rotate a safe dialer when the user touches the dialer in a circle. As soon as i touch the dialer, i save the x-value. In the move phase of the event, i check if the new x-value = smaller then the old x-value. If so, if the difference is more then 10, i rotate the dialer with rotation = rotation - 6.

So far so good. Only problem is, it only works in the upper half of the dialer (circle).

I know it has something todo with checking the y-value too, but i can't figure it out. here's the code i got so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function AddsEvent(event)
 
if event.phase == "began" then
        print("began")
        StartX = event.x
elseif event.phase == "moved" then
        print("moved"..event.x)
        print("old-X"..StartX)  
        if event.x < StartX then
                if (StartX-event.x) > 10 then
                        print ("Rotate left, diff: "..(StartX-event.x))
                        event.target.rotation = event.target.rotation - 6
                        StartX = event.x
                end                     
        else
                if (event.x-StartX) > 10 then
                        print ("Rotate right, diff: "..(StartX-event.x))
                        event.target.rotation = event.target.rotation + 6
                        StartX = event.x
                end             
        end     
                        
elseif event.phase == "ended" then
        print("ended")
                        
end
views:1498 update:2011/12/30 9:10:41
corona forums © 2003-2011