1
我想每次按下button2時按下按鈕1(點擊button2後button1顯示style.down然後style.up並在clicklistener中執行功能)。我發現在that後類似的問題,但不適合我。以編程方式點擊場景2D中的按鈕LibGDX
Android中我只需要調用performAction()
的方法,但我不能搜索類似的方法,使用LibGDX圖書館
我想每次按下button2時按下按鈕1(點擊button2後button1顯示style.down然後style.up並在clicklistener中執行功能)。我發現在that後類似的問題,但不適合我。以編程方式點擊場景2D中的按鈕LibGDX
Android中我只需要調用performAction()
的方法,但我不能搜索類似的方法,使用LibGDX圖書館
我弄明白:
的溶液(this後的啓發)
button2.addListener(new ClickListener(){
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
InputEvent event1 = new InputEvent();
event1.setType(InputEvent.Type.touchDown);
button1.fire(event1);
return true;
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
InputEvent event2 = new InputEvent();
event2.setType(InputEvent.Type.touchUp);
button1.fire(event2);
doSmth();
}
});
我真的想看看這個,因爲我沒有線索,並沒有出現在第一次搜索。很好的問題和很好的回答。 – Madmenyo
請發表您的解決方案作爲答案:-) – Sebastian