how to drag and drop actors on libgdx scene2d?(如何在 libgdx scene2d 上拖放演员?)
问题描述
我正在使用 libGDX 开发游戏,我想知道如何拖放 Actor.我已经搭建好舞台并画好了演员,但我不知道如何触发该事件.
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 event.
请尝试帮助我使用我自己的架构.
Please try to help me using my own architecture.
推荐答案
看看 libgdx 示例中的示例.这是来自 libgdx 测试类的拖放测试:DragAndDropTest
Take a look at the Example in the libgdx examples. Here is the drag and drop test from the libgdx test classes: DragAndDropTest
如果您只想拖动/滑动您的 Actor,您需要向其添加一个 GestureListener 并将您的 Stage 传递给 Inputprocessor,如下所示:Gdx.input.setInputProcessor(stage);
.这是 来自 libgdx 的 GestureDetectorTest.对于拖动事件,它是 Flinglistener.
If you just want to drag/slide your Actor around you need to add a GestureListener to it and pass your Stage to the Inputprocessor like this:Gdx.input.setInputProcessor(stage);
.
Here is the GestureDetectorTest from libgdx.
For drag events its the Flinglistener.
这篇关于如何在 libgdx scene2d 上拖放演员?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!