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:
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
Anyone? [import]uid: 50459 topic_id: 19071 reply_id: 319071[/import]