Search code examples
androidlibgdxdrag-and-dropactoroverlap

Drag&Drop + Overlap in LibGDX


First of all, excuse me for my English, I have it a little rusty. I have a problem with LibGDX. I am making, so to speak, a card game, and I need the cards to have the following effects:

  • An action is done when you only click on it.
  • Another action is done when the card is dragged.

Both things I have managed to work, the problem comes when, after releasing the card, I must call a function and later return the card to its original position. The following code is the one that I associate with each Actor, but in the Override methods I don't find any for the DROP.

Can you help me?

Thank you very much in advance!

My Code


Solution

  • ClickListener has a "touchUp" method, which is called when the mouse button (or finger touch) goes up. This is what you want to use when releasing the card. More info here:

    https://libgdx.badlogicgames.com/ci/nightlies/docs/api/com/badlogic/gdx/scenes/scene2d/utils/ClickListener.html#touchUp-com.badlogic.gdx.scenes.scene2d.InputEvent-float-float-int-int-