Dragging Containers and Nested Containers

Hello all,

I’ve been developing a “click and drag” educational card game. The concept is very simple, there are question cards and answer cards and they have to be attached together. It;s just the sort of thing I found that I could really do with in some of my lessons. All cards are containers with shapes, text and some shapes with physics to check for collisions.

I want to make it so that, when I connect to pieces, dragging one drags both. I know that the better aproach would be to create a new class called “AttatchedCards” and use that to store both of the containers, but I wanted to try a simpler, uglier approach. I just added the answer card to the question card.

Now, all cards have a drag event. These events exist on the containers. So is it possible to have my Outer container drag event override the nested container drag event? At the moment, when I drag an answer card, it moves by itself, and when I drag the question card, it drags both cards the way I’d want to!

nested%20container%20glitch

I will post the card if requested, but I’m slightly embarrassed as I don’t know how to display code in a nice format in these forums. If someone can explain that to me, I’ll gladly do it.

I can at least help you with this. You can use markdown in this forum.
Check https://commonmark.org/help/ to learn how to use it.

I did something like this in the past, and just kept a tracked list (for each draggable item) of linked/associated children that would have their positions updated when the item was dragged.