Stop Rotation

Creating Games? Developing something for fun?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Stop Rotation

Post by Surbhit29 » Mon Aug 27, 2012 10:23 am

I have used revRotatePoly under mouseUp. So whenever I drag the polygon to a particular location and drop it at that location, it will rotate to a desired angle. So far no problem.
Now problem arises when that particular polygon is clicked by me. Whenever it is clicked it rotates to that particular angle. Now is their anyway to stop this rotation whenever it is clicked. I want the polygon to rotate only when it is dragged and dropped at the desired position.
How can that be done? Is their any different handler that I should be using?

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Stop Rotation

Post by shaosean » Tue Aug 28, 2012 1:21 am

Check the location.. If it is already in the spot, do not rotate it..

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Stop Rotation

Post by Surbhit29 » Tue Aug 28, 2012 6:33 am

Hi Shaosean
I've been trying that but cannot find the right command. I've searched dictionary, user guide, forum everywhere. Is their any command like "Stop revRotatePoly"?
Surbhit

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Stop Rotation

Post by shaosean » Tue Aug 28, 2012 10:24 am

wrap it in an if statement

Code: Select all

if (the location of me <> the location of kTheOtherPolygon) then
  revRotatePoly me, 45
end if
or just set the degrees to rotate to zero..

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Stop Rotation

Post by Surbhit29 » Tue Aug 28, 2012 11:22 am

the command is already in an "if" statement.
But whenever it is clicked it rotates at certain angle.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Stop Rotation

Post by Klaus » Tue Aug 28, 2012 12:32 pm

Please post your script, guessing is way too timeconsuming!

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Stop Rotation

Post by Surbhit29 » Tue Aug 28, 2012 12:50 pm

HI Klaus
Here is my script

Code: Select all

on mouseUp
   if within (graphic "Rectangle", the mouseloc) then
      revRotatePoly the long ID of graphic "outerPoly",45
      end if
end mouseUp
Its fine when an object is dragged from one place into "Rectangle" and it gets rotated by an angle 45. But when an object is dragged inside the rectangle and is left there only it should not rotate.
How can this be achieved.

Surbhit

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Stop Rotation

Post by Klaus » Tue Aug 28, 2012 1:33 pm

Your script does not cover your condition!?

You only check if the current mouseloc (sic!) is within the graphic "Rectangle"
but you wanted to check some other condition as Sean showed in her script!

Pseudocode, do not copy/paste!

Code: Select all

on mouseUp
   if within (graphic "Rectangle", the mouseloc) AND (the loc grc "outerpoly" is NOT "where it should be")  the then
      revRotatePoly the long ID of graphic "outerPoly",45
      end if
end mouseUp
Please do not think too much in "computer" terms, try to explain and solve the logics of your problem to yourself in plain english
and if that was susccessful, you can translate it 1:1 into Livecode almost everytime!

Best

Klaus

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Stop Rotation

Post by Surbhit29 » Wed Aug 29, 2012 5:49 am

Hi Klaus,

Its giving me the same result. I want that once the polygon is inside the rectangle no matter how much time we click it or drag inside that rectangle it should not rotate.
Because whenever we click it or drag it inside the rectangle it will keep on rotating because of the mouseUp handler.

Surbhit

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Stop Rotation

Post by shaosean » Wed Aug 29, 2012 6:01 am

Best to post the code you are using so we can help that way, otherwise, the advice above is what you need to do..

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Stop Rotation

Post by Surbhit29 » Wed Aug 29, 2012 6:34 am

Hi Shaoesean,

I have already posted my script.
Please check my earlier post in this topic.

Surbhit

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: Stop Rotation

Post by shaosean » Wed Aug 29, 2012 6:48 am

ahh.. missed that.. looks like you will need to set a flag to control it.. you can either use a script-wide variable or a custom property on the object and then check that..

Code: Select all

local sRotateFlag  // this will default to false

on mouseUp
   if within (graphic "Rectangle", the mouseloc) AND (sRotateFlag = FALSE) then
      revRotatePoly the long ID of graphic "outerPoly",45
      put FALSE into sRotateFlag
   end if
end mouseUp

Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Re: Stop Rotation

Post by Surbhit29 » Thu Aug 30, 2012 1:54 pm

Thanks a lot Shaosean.
Will try that.

Surbhit

Post Reply