0

実行が完了するまで、再度呼び出すことなく if ステートメント (またはその他の関数) を呼び出すにはどうすればよいですか? 別の関数 (別のクラス) を呼び出す更新関数がありますが、すべての更新を実行するため、ユーザーは IF ステートメントを実際に完了する時間がないため (if ステートメントはユーザー入力に依存します)、何も返さないか、または最初の部分だけ。

コード (アップデートがある場所):

public void Update(){
    if(Mouse.isButtonDown(0)){
        changeTile();
    }
    while(Keyboard.next()){
        if(Keyboard.getEventKey() == Keyboard.KEY_RIGHT && Keyboard.getEventKeyState()){
            moveIndex();
        }
        if(Keyboard.getEventKey() == Keyboard.KEY_LEFT && Keyboard.getEventKeyState()){
            moveIndexBack();
        }
    }
}

changeTile 関数:

    public void changeTile(){
    boolean start = true;

    if(start){
        while(Mouse.next()){
        if(Mouse.getEventButton() == 0 && Mouse.getEventButtonState()){
                    //system uses tileTypes because player textures are tiletypes itself, so in the end we can let them swim by changing tiletypes
                    int xCoord = (int) Math.floor(Mouse.getX() / 64);
                    int yCoord = (int) Math.floor((HEIGHT - Mouse.getY() - 1) / 64);
                    tileType tile1 = map[xCoord][yCoord].getType();
                    System.out.println("first tile is set to:" + tile1);
                    start = false;
            }
        }
    }

    if(!start){
        while(Mouse.next()){
            if(Mouse.getEventButton() == 0 && Mouse.getEventButtonState()){
                int xCoord2 = (int) Math.floor(Mouse.getX() / 64);
                int yCoord2 = (int) Math.floor((HEIGHT - Mouse.getY() - 1) / 64);
                tileType tile2 = map[xCoord2][yCoord2].getType();
                System.out.println("second tile is set to:" + tile2);
            }
        }
    }
4

0 に答える 0