Page 1 of 1

Command problem

Posted: Thu Aug 23, 2012 12:32 pm
by Surbhit29
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

Re: Command problem

Posted: Thu Aug 23, 2012 12:45 pm
by shaosean
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

Re: Command problem

Posted: Thu Aug 23, 2012 1:09 pm
by Surbhit29
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?

Re: Command problem

Posted: Thu Aug 23, 2012 2:16 pm
by Surbhit29
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.

Re: Command problem

Posted: Thu Aug 23, 2012 2:20 pm
by dunbarx
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

Re: Command problem

Posted: Thu Aug 23, 2012 2:54 pm
by Surbhit29
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 :)