我在Android上使用libGDX。我設置舞臺並添加了自定義繪畫的自定義動作。它工作正常。但是,我無法通過此演員的InputListener爲touchDragged方法獲取任何日誌。即使它內部的代碼也不會運行。我在libGDX中錯過了在Actor上獲取InputEvent的內容?
這裏是需要暴露在代碼:
public class CustomActor extends Actor {
public CustomActor() {
this.setListener(new InputListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
return true;
}
@Override
public void touchDragged(InputEvent event, float x, float y, int pointer) {
//This log doesn't print up!
Gdx.app.log("CustomActor","touchDragged");
//This code doesn't work either
Vector2 v = CustomActor.this.localToParentCoordinates(new Vector2(x,y));
CustomActor.this.setPosition(v.x, v.y);
}
});
}
}
誰能幫助我在這裏對我缺少什麼?
感謝BennX,我已經在create()方法中完成了這個工作。在舞臺上添加的小部件會在連接的InputListeners中獲取日誌,但不會自定義擴展的演員。小部件已經從演員派生出來,我只是感到驚訝。你現在可以提供任何幫助嗎? – CodenameLambda1