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 »

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 »

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 »

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 »

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 »

the command is already in an "if" statement.
But whenever it is clicked it rotates at certain angle.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Stop Rotation

Post by Klaus »

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 »

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: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Stop Rotation

Post by Klaus »

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 »

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 »

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 »

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 »

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 »

Thanks a lot Shaosean.
Will try that.

Surbhit
Post Reply