Move clicked elements

I’m trying to design a game like the above picture.
I have successfully brought one block in. I can move a single block very easily. But, When I brink second block Still first block only moves…

I guess I’m following wrong structure (I’m directly adding blocks in main.collection and listening input in each block).

Please help me with this asap. Thanks in advance…

1 Like

How do you detect which block that was clicked?

That flow I can’t understand. I don’t know to identify which block is clicked.

This is my project structure…

  • main.collection have level_1.colletion
  • level_1.collection has brick_1.collection and brick_2.collection

  • I just want to click and drag brick_1, brick_2.

Help me to figure it out.

You don’t have to create a collection for each block. I recommend you create game objects instead. You create one collection for the level and attach game objects to that collection e.g., level_1.collection has brick1.go and brick2.go.

@britzl created an example that shows how you can handle the input on game objects:

He also made an extension that handles input:

You can test the demo here (check “cursor”):
https://britzl.github.io/Defold-Input/

ps: @britzl the demo on the community page is outdated https://www.defold.com/community/projects/97546/

2 Likes