0
嗨,所以我有這個球,我試圖通過使用touchDown方法保持在空中。這對我很有用,但它不一致,因爲我不得不重複點擊屏幕才能聽到它,有時它不會做任何事情。LibGdx輸入處理器touchDown正在播放
Gdx.input.setInputProcessor(new InputController(){
@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button){
random = new Random();
int rand = random.nextInt(2);
Vector3 mouseCoords = new Vector3(screenX, screenY, 0);
camera.unproject(mouseCoords);
mouseCoords.scl(WORLD_TO_BOX);
if(ball.getFixtureList().get(0).testPoint(mouseCoords.x, mouseCoords.y)){
movement.y = upPos;
if(rand == 1){
movement.x = speedPos;
}else if(rand == 0){
movement.x = speedMinus;
}
System.out.println("Reached the loop");
}
return true;
}
@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button){
movement.x = 0.00f;
movement.y = 0.00f;
return false;
}
});
我有一個名爲inputController的類,它擴展了InputProcessor,所以我可以選擇和選擇要使用的控件。我不知道它的重力是不是允許形狀向上移動,或者代碼在設想時不會觸發。
任何想法?