我有一个屏幕:
WorldScreen implements Screen, InputProcessor{
....
stageGui.addActor(storyActor);
....
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
}
}
我有一个演员:
public class StoryActor extends Group {
private InputListener listener = new InputListener() {
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
event.handle();
}
}
}
单击演员时,首先处理来自WorldScreen的修饰。然后稍后处理StoryActor的touchUp。
我如何实现首先要处理演员?
答案 0 :(得分:2)
不是在WorldScreen中实现InputProcessor。例如,为InputProcessor创建一个新类:WorldScreenInputProcessor implements InputProcessor
之后,您可以使用InputMultiplexer处理多个InputProcessor:
InputMultiplexer multiplexer = new InputMultiplexer();
//What you add first has higher priority
multiplexer.addProcessor(stageGui); //Input of your Actor
multiplexer.addProcessor(new WorldScreenInputProcessor());
Gdx.input.setInputProcessor(multiplexer);
答案 1 :(得分:1)
看看https://github.com/libgdx/libgdx/wiki/Event-handling#inputmultiplexer如何使用输入多路复用器,它应该可以解决您的问题。