我正在尝试使用ActorGestureListener在LibGdx中实现角色手势。以下代码绘制了角色,但pan方法未被调用。我错过了什么吗?
我使用的是LibGdx 1.3.1版本。
我使用的是LibGdx 1.3.1版本。
public class MyApp extends ApplicationAdapter {
private Stage stage;
@Override
public void create() {
stage = new Stage(new ExtendViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));
Gdx.input.setInputProcessor(stage);
final Shape circle = new Circle(); // Actor that draws a texture
stage.addActor(circle);
circle.addListener(new ActorGestureListener(){
public void pan (InputEvent event, float x, float y, float deltaX, float deltaY) {
Gdx.app.log("", "pan");
event.getTarget().moveBy(deltaX, deltaY);
}
});
circle.setTouchable(Touchable.enabled);
}
@Override
public void render() {
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
}
}