2017-04-21 26 views
0
public static void showHs(boolean remove){ 
    if(remove){ 
     table.getCell(hsLabel).getActor().setVisible(true); 
     table.getCell(hsLabel).getActor().setWidth(labelsWidth); 
    }else { 
     table.getCell(hsLabel).getActor().setVisible(false); 
     table.getCell(hsLabel).getActor().setWidth(0); 
    } 
} 

setVisible()不會刪除actor - 如果我使用remove()作品,但它永遠不會將actor放在同一位置,它仍然需要該單元格。 有沒有像Visibility.GONE這樣的方法?我搜索並在這裏結束。如何臨時刪除scene2d中的actor

回答

0
public static void showHs(boolean remove){ 
    if(remove){ 
     table.getCell(hsLabel).getActor().setVisible(true); 
     table.getCell(hsLabel).getActor().setWidth(labelsWidth); 
     table.getCell(hsLabel).expandX(); 
    }else { 
     table.getCell(hsLabel).getActor().setVisible(false); 
     table.getCell(hsLabel).getActor().setWidth(0); 
     table.getCell(hsLabel).width(0); 
    } 
} 

通過設置0寬度細胞制定出來,但也許還有一個有道

0

下面是關於如何使你的角色裏你的表設定的知名度一種簡單的方法。您不必將演員的寬度設置爲零以使其「消失」。

中的第二個參數包含是Identity,如果爲true,則會使用==比較。如果爲false,則會使用.equals()比較。 如果數組包含值,則爲true;如果不包含,則爲false。

public static void showHs(boolean visible,Actor yourActor){ 
     if(table.getChildren().contains(actor,true){ 
       actor.setVisible(visible); 
     } 
    }