Constraint of Rotations?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
pastrana
Posts: 17
Joined: Wed Jun 14, 2006 9:54 pm
Contact:

Constraint of Rotations?

Post by pastrana » Mon Mar 08, 2010 10:07 pm

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
Attachments
Picture 3.png
Picture 3.png (43.37 KiB) Viewed 2731 times

Regulae
Posts: 136
Joined: Tue Oct 20, 2009 6:05 am

Re: Constraint of Rotations?

Post by Regulae » Tue Mar 09, 2010 5:24 am

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

Post Reply