Page 1 of 1

Constraint of Rotations?

Posted: Mon Mar 08, 2010 10:07 pm
by pastrana
I want to create a puzzle with several square images and:
-Constraint image rotation (via mouseups) to 90, 180, 270 then get back to 0 (4 movements)
-get the number according to the rotation grade (is the picture at 180º?) and send that value to a variable so I can compare it with other pictures
-if the values I want are true then execute (an animation, etc..)

I already got the rotations to work but I can't find in the documentation how I can constraint them until it gets to 270º

any help?
(attached drawing with concept)

thanks!

Ben

Re: Constraint of Rotations?

Posted: Tue Mar 09, 2010 5:24 am
by Regulae
One approach to some of your requirements might be to put the following in the script of your images:

Code: Select all

on mouseUp
   rotate image id (the id of me) by -90
   put the currentRotation of me into myRotation
   if myRotation is empty then
      set the currentRotation of me to 1
      pass mouseUp
   end if
   put myRotation + 1 into myRotation
   if myRotation > 3 then
      put 0 into myRotation
   end if
   set the currentRotation of me to myRotation
   put myRotation
end mouseUp
This rotates the image 90 degrees clockwise with each mouseUp. The orientation is stored as a custom property of the image, currentRotation, which can take 0,1,2,3 as its values. The very first time you click the image, the currentRotation of the image is empty- the image is rotated 90 and the currentRotation set to 1. The final “put myRotation” is just to see how things work.

Regards,

Michael