Image rotation with MouseStillDown not very smooth
Posted: Thu Dec 20, 2012 3:21 pm
				
				Hey guys, 
I am trying to rotate an image "CannonBarrel.png" according to the position of the finger on the screen. I am therefore using the "on MouseStillDown" still down handler in combination with "mouseLoc". Everything works fine and the image is adjusting accordingly to the position of the finger. The big problem is that the movement is not very smooth. You can actually see the image "jumping" and not turning smoothly. If you move very fast, the on the screen it is even possible the the image jumps by more than 20 degrees.
I guess this is related to the "update rate" of the "on MouseStillDown" handler but I am not sure. Does anybody know how I can increase the smoothness of the image rotation?
This is the code I am using:
			I am trying to rotate an image "CannonBarrel.png" according to the position of the finger on the screen. I am therefore using the "on MouseStillDown" still down handler in combination with "mouseLoc". Everything works fine and the image is adjusting accordingly to the position of the finger. The big problem is that the movement is not very smooth. You can actually see the image "jumping" and not turning smoothly. If you move very fast, the on the screen it is even possible the the image jumps by more than 20 degrees.
I guess this is related to the "update rate" of the "on MouseStillDown" handler but I am not sure. Does anybody know how I can increase the smoothness of the image rotation?
This is the code I am using:
Code: Select all
on MouseStillDown
   put item 1 of the mouseLoc into lMouseUpX
   put item 2 of the mouseLoc into lMouseUpY
      
   put item 1 of the the location of the image "CannonBarrel.png" into lBowLocX
   put item 2 of the the location of the image "CannonBarrel.png" into lBowLocY
   
   put (lMouseUpX - lBowLocX) *-1 into lDiffX
   put (lMouseUpY - lBowLocY)  into lDiffY
   
   if lMouseUpX < lBowLocX then 
   
      put atan (lDiffY / lDiffX) *180 / pi into lAngle
      set the angle of image "CannonBarrel.png" to lAngle
   end if
   
end MouseStillDown