how to drag and drop actors on libgdx scene2d?

前端 未结 3 854
鱼传尺愫
鱼传尺愫 2021-02-02 16:04

I\'m developing a game using libGDX and I would like to know how I can drag and drop an Actor. I\'ve made my stage and drawn the actor, but I don\'t know how to trigger that eve

3条回答
  •  温柔的废话
    2021-02-02 16:52

    If you don't want to use DragAndDrop class, you can use this:

    actor.addListener(new DragListener() {
        public void drag(InputEvent event, float x, float y, int pointer) {
            actor.moveBy(x - actor.getWidth() / 2, y - actor.getHeight() / 2);
        }
    });
    

    Edit: method drag instead touchDragged

提交回复
热议问题