Command problem

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
Surbhit29
Posts: 80
Joined: Thu Aug 16, 2012 1:25 pm

Command problem

Post by Surbhit29 » Thu Aug 23, 2012 12:32 pm

Hi,
I have given a command "revRotatePoly" to a "Polygon" to rotate at a certain angle when dragged inside a particular graphic.
But now I want to give it a command to rotate back to its normal size when taken to its old position or to rotate at some other angle when taken to some place else.
I am getting confused on how to do that. I know that when we put minus sign in front of angle it will rotate anti clockwise.
But how to give a command to an object after it has performed a certain action.
Please help

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

Re: Command problem

Post by shaosean » Thu Aug 23, 2012 12:45 pm

If you rotate the polygon 45 degrees, just rotate it -45 degrees to reset it.. All you really will need to do is keep track of the current rotation and than do some quick math to figure out the difference needed to rotate it to a given degree..

newDegree - currentDegree

So using the above example, we want to take the polygon from 0 degrees to 45 degrees so: 45 - 0
Now we want to rotate back to 0 degrees: 0 - 45
We shall rotate again to 45 degrees: 45 - 0
Now we want to rotate it to 60 degrees (from 0): 60 - 45
Now we want to rotate it to -150 degrees (from 0): -150 - 45

Hope that helps

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

Re: Command problem

Post by Surbhit29 » Thu Aug 23, 2012 1:09 pm

I get that. But how to all these at one time.
I want an object to go to one place and get rotated and after that to take it some place else and rotate it at different angle.
How should I write a command for such a situation.
I can make an object to do only one thing, how can I make him to do different things?

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

Re: Command problem

Post by Surbhit29 » Thu Aug 23, 2012 2:16 pm

I am so sorry Shosean.
Actually I wasn't using the right object name in the command and thats why the command was not running. Had a little confusion.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10323
Joined: Wed May 06, 2009 2:28 pm

Re: Command problem

Post by dunbarx » Thu Aug 23, 2012 2:20 pm

Hi.

Did you really mean "drag" an object into a graphic? It seems you want to write a script to queue a series of motions and rotations.

If so, you would (pseudoCode):

- set the loc of yourPolygon to someLoc
- rotate yourPolygon someAngle
- set the loc of yourPolygon to someOtherLoc
- rotate yourPolygon someOtherAngle
- etc.

Of course you can use the "move" command "in time" if you want it to slide across the screen, instead of simply appearing at the desired location. And as you have seen, you can keep track of current, original and future angles so that you maintain control over the object. This can be stored in a custom property of the object.

Are we talking about this correctly? It is hard to clearly describe what one wants, sometimes, and this takes a bit of back and forth. But it all works out in the end.

Write back...

Craig Newman

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

Re: Command problem

Post by Surbhit29 » Thu Aug 23, 2012 2:54 pm

Thnx Craig.
Actually I did everything right but mentioned the name of the object wrong in the script. And thats why I was getting errors and was unable to execute.

Thnx again for the reply :)

Post Reply