• 2D
  • Drag and drop / movment in a board game

Hello, thanks in advice. I'm trying to make a simple board game and don't understand the "drag and drop" methods(I use GDscript). I need take a game piece and move it to other control node. It can be made taking the sprite and when the player drop it, the sprite is now child to another control node, at finish is need flush the other sprite, but i'm trying this 3 days ago and the tutorials do not have the same objective, "Drag and drop (GUI)" tutorial have the base of my concept, but i can't make it work. all help and links are welcome, sorry for bad English

a month later

@Shin-NiL said: Did you see the drag and drop official demo?

I have found the drag and drop demo, and am trying to figure out how it works by experimentation.

It would still be useful to have a tutorial that explains what the functions do and how they are related. E.g. in a scene where I have a game piece and a drop target, which functions do I define for each of the components and how do they pass data. Are there any other functions related to drag and drop than the following?

  • get_drag_data
  • set_drag_preview
  • drop_data
  • can_drop_data

The basic idea is to have a GamePiece node that has a texture and can be moved around by dragging and dropping. There should also be one or more game board Positions onto which the GamePiece can be dropped. If the Position is empty, the GamePiece can be dropped, but otherwise it must be dropped elsewhere.

What types of nodes should be used for the GamePiece and Position scenes (two Control nodes)? When moving the GamePiece, how can it be set to follow the mouse, rather than being stationary at the original position?