See if you can do this! moving groups around a stack

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
William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

See if you can do this! moving groups around a stack

Post by William Jamieson » Tue Jun 25, 2013 2:45 pm

So i got a really basic yet really good question. See if you can do this!

What I am trying to do is have the user drag one object and as that object moves horizontally, a separate group moves accordingly. For the sake of this example, It can be as simple as moving a red square with your finger and having a group of blue squares move accordingly to the red square. When I say accordingly i mean if you drag the red square over 30 pixels the group with the blue squares will move 30 pixels in the same direction at the same speed.

So looking at the available livecode functions that can be used I think it can be done with: touchmove, mousemove, move, but most likely movecontrol. Although i have not used the movecontrol function before and am not sure how to go about using it. Any insights to how I would go about this would be much appreciated. Also, nothing has been posted yet about the moveControl function so it would be great if someone was able to share their experience. Thank you.

-Will

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

Re: See if you can do this! moving groups around a stack

Post by dunbarx » Tue Jun 25, 2013 4:36 pm

Hi,

Of course this is what groups are for, but if they did not exist at all, I made three buttons. In button 1 I wrote:

Code: Select all

on mouseDown
   repeat with y = 1 to 3
      set the startX of btn y to item 1 of the loc of btn y
   end repeat
end mouseDown

on mouseMove
   if the mouse is down then
      put the startX of me - item 1 of the mouseLoc  into xOffset
      repeat with y = 1 to 3
       set the loc of btn y to the startX of btn y - xOffset  & "," & item 2 of the loc of btn y
      end repeat
   end if
end mouseMove
Craig Newman

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: See if you can do this! moving groups around a stack

Post by William Jamieson » Thu Jun 27, 2013 2:53 pm

Youre right! Thank you fro answering that question for me. I am going to post a similar question now about being able to move an object smoothly while sending messages. Please take a look at my new post. Thank you for your help dunbarx! you really got me on the right track!

Post Reply