Drag a group

Create fast, sprite powered games with Animation Engine, co-developed with DerBrill Software!

Moderators: heatherlaine, kevinmiller, robinmiller, malte

Post Reply
Ron Zellner
Posts: 106
Joined: Wed May 31, 2006 9:56 pm
Location: College Station, Texas
Contact:

Drag a group

Post by Ron Zellner » Sun Jan 21, 2007 10:21 pm

I want the user to be able to drag & drop a group (set of objects that have been grouped). Can this be done in Revolution itself, if not, can Arcade Engine provide this function? Is there an example somewhere?
Thanks.

Ron Zellner
Posts: 106
Joined: Wed May 31, 2006 9:56 pm
Location: College Station, Texas
Contact:

One solution tried

Post by Ron Zellner » Sun Jan 21, 2007 11:05 pm

I tried this:

on mouseDown
grab group "CHTop" (also tried 'Grab me')
end mouseDown

At least the objects in the group all move, but they do not keep their relative positions, the group configuration changes drastically as it is dragged around.

mblackman
Posts: 21
Joined: Fri Apr 14, 2006 12:02 pm
Location: Perth

Post by mblackman » Fri Jan 26, 2007 5:27 am

Ron, maybe try something like this in the group script-

on mouseDown pMouseBtnNum
if pMouseBtnNum is 1 then set the cDragging of me to true
set the hOffset of me to the mouseh - item 1 of the location of me
set the vOffset of me to the mousev - item 2 of the location of me
end mouseDown

on mouseMove pMouseH,pMouseV
if the cDragging of me then set the location of me to pMouseH - the hOffset of me, \
pMouseV - the vOffset of me
end mouseMove

on mouseUp pMouseBtnNum
if pMouseBtnNum is 1 then set the cDragging of me to false
end mouseUp

Howlernator
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 18
Joined: Wed Oct 13, 2010 4:44 am

Re: Drag a group

Post by Howlernator » Sat Nov 27, 2010 3:02 am

is there a way to do this? i've just been trying with ae constrainRectangular, and can only get it working with single objects (button, img). as soon as I try the logic on a group... no movement on the drag action.

Any ideas? Need user to be able to drag a button (with downstate) + an accompanying text field.

Howlernator
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 18
Joined: Wed Oct 13, 2010 4:44 am

Re: Drag a group

Post by Howlernator » Sat Nov 27, 2010 3:40 am

Well,

This may have unknown drawbacks, but a simple win exists in the following:

Code: Select all

on constrainRectangularCallback
   set the loc of fld "texty" to the loc of me
end constrainRectangularCallback

this allows the extra txt field to 'follow' the dragged item around. any gotchyas?

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

Re: Drag a group

Post by shaosean » Sat Nov 27, 2010 1:27 pm

Have you tried setting the opaque property of the group to true?

Post Reply

Return to “Animation Engine”