At 7:26 AM -0500 3/31/06, Philip Regan wrote:
I would like for them to move parallel to each other. So, when the
user selects a group of objects, they move as a group in their same
positions relative to each other.
Ah. That should be a simple matter of deciding how the group is
moving -- i.e., finding the dx and dy that you're going to add to
every X and Y position -- and then simply adding it to the positions
of all objects.
The math I cooked up to do this is (in awful psuedocode):
(Object(0).Orig(X, Y) - Object(0).New(X, Y)) + Object(n).(X, Y)
Er. This is trying to do too much at once. You must already have a
dx and dy calculated somewhere; typically this is done in a MouseDrag
event by something like:
Dim dx as Integer = X - mLastMouseX
Dim dy as Integer = Y - mLastMouseY
if dx = 0 and dy = 0 then return // mouse hasn't moved
Then, simply do something like:
for i as Integer = 0 to UBound( Objects )
Objects(i).X = Objects(i).X + dx
Objects(i).Y = Objects(i).Y + dy
next
HTH,
- Joe
--
Joseph J. Strout
joe at strout dot net
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|