2016-05-06 22 views
0

所以我用Gdx.input.isKeyPressed(以前的InputProcessor)以獲取輸入和移動2D玩家喜歡這個屏幕上嘗試:LibGDX - 是否有可以同時按下的最大數量的按鍵?

private void handleInput(float delta) { 
    if(Gdx.input.isKeyPressed(Input.Keys.UP)) 
     moveTo(new Vector2(0, -speed * delta)); 

    if(Gdx.input.isKeyPressed(Input.Keys.DOWN)) 
     moveTo(new Vector2(0, speed * delta)); 

    if(Gdx.input.isKeyPressed(Input.Keys.LEFT)) 
     moveTo(new Vector2(-speed * delta, 0)); 

    if(Gdx.input.isKeyPressed(Input.Keys.RIGHT)) 
     moveTo(new Vector2(speed * delta, 0)); 

    if(Gdx.input.isKeyJustPressed(Input.Keys.SPACE)) 
     attack(); 
} 

運動如預期運作,對角線爲好。但由於某種原因每當玩家移動向上和向左移動,向下和向左移動向下和向右移動attack函數在最後不能因爲某種原因調用。這是否與可以同時按下並處理的有限數量的按鍵有關?

回答

相關問題