drag&drop and detecting hover/drop on other object?

Hi, I need 2 functionalities:

  1. while dragging object1 over object2, make object2 brighter, to let user know dropping object1 will be dropped on object2

  2. while dropping object1 on object2 detect it.

I can save coordinates of object2, and when moving/dropping object1 check if object1 square collides with saved coordinates of object2. Is there any better way?

Some collision function? (but without applying physics there, just simple draging and dropping, like icons on windows desktop) 

Google DMC drag drop library. It’s free and works well, saved me a lot of time.

thanks, looking into it right now. Do you know maybe if object can be DragTarget and DropTarget at the same time?

If I understand you correctly you want to be able to drag an object, while also being able to drop other objects onto it. That’s definitely possible.

let me elaborate a bit: I want all objects to be draggable and can be dropped on the same all objects

So each object should be draggable + implement DropTarget from dmc 

Yep, in my case I have football shirts and text objects that can be dragged onto each other.

can you share a bit of code? 

I’m looking at https://github.com/dmccuskey/DMC-Corona-Library/blob/master/examples/dmc_dragdrop/DMC-dragdrop-OOP/main.lua

local dropTarget2 = DropTarget.create( { format={ “blue” }, color=color_lightblue } )

dropTarget2:addEventListener( “touch”, dragItemTouchHandler )

something like that should work? or are you using different method to make object both draggable and droppable?

Am out at the moment, will try and dig something out this evening.

thanks, in the meantime I’ll test examples and see what can I do with it :slight_smile:

I tried to play with this example: https://github.com/dmccuskey/dmc-dragdrop/tree/master/examples/dmc-dragdrop-basic

Added: 

DragMgr:register( dragItem, { dragStart=dragStartHandler, dragEnter=dragEnterHandler, dragOver=dragOverHandler, dragDrop=dragDropHandler, dragExit=dragExitHandler, dragStop=dragStopHandler, })

to make other item target for droping

and

dropTarget:addEventListener( 'touch', dragItemTouchHandler )

to make dropTarget also draggable

So I have now 2 objects, both are draggable and droppable for a few first seconds :frowning:

Here movie I recorded: https://www.screencast.com/t/oojnOIGbj6PW

Help?

I started digging into code of dmc and I see it’s not as flexible - for example it assumes there’s always proxy when moving object, so you move proxy instead of object. And I’d like to move actual object… 

@nick_sherman in your game are you using proxy for dragging objects?

Yes I just create an exact copy of the object and hide the original if required.

Google DMC drag drop library. It’s free and works well, saved me a lot of time.

thanks, looking into it right now. Do you know maybe if object can be DragTarget and DropTarget at the same time?

If I understand you correctly you want to be able to drag an object, while also being able to drop other objects onto it. That’s definitely possible.

let me elaborate a bit: I want all objects to be draggable and can be dropped on the same all objects

So each object should be draggable + implement DropTarget from dmc 

Yep, in my case I have football shirts and text objects that can be dragged onto each other.

can you share a bit of code? 

I’m looking at https://github.com/dmccuskey/DMC-Corona-Library/blob/master/examples/dmc_dragdrop/DMC-dragdrop-OOP/main.lua

local dropTarget2 = DropTarget.create( { format={ “blue” }, color=color_lightblue } )

dropTarget2:addEventListener( “touch”, dragItemTouchHandler )

something like that should work? or are you using different method to make object both draggable and droppable?

Am out at the moment, will try and dig something out this evening.

thanks, in the meantime I’ll test examples and see what can I do with it :slight_smile: