1
添加圖像我有這個表:Libgdx刪除,並從細胞
table.add(image1).size(image1.getWidth(), image1.getHeight());
table.add().size(image1.getWidth(), image1.getHeight()).row();
table.add().size(image1.getWidth(), image1.getHeight());
table.add().size(image1.getWidth(), image1.getHeight());
我想,當我點擊空單元格,圖像從細胞中刪除,並添加到單擊的單元格。例如,當我點擊第三個單元格時,從第一個單元格中移除image1並將其添加到第三個單元格中。怎麼辦?
更新2:
我寫了這個代碼,但是當我點擊CELL1,此搜索不會添加表,並添加合適的屏幕上,點擊CELL0不起作用。
Group group = new Group();
group.addActor(image1);
group.addActor(image2);
group.addActor(image3);
root.add(group).size(16, 16);
root.add(image4).size(image4.getWidth(), image3.getHeight()).row();
root.add(image5).size(image5.getWidth(), image4.getHeight());
root.add(image6).size(image6.getWidth(), image5.getHeight());
stage.addActor(root);
stage.setDebugAll(true);
root.getChildren().get(1).addListener(new InputListener(){
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
root.getCells().get(1).clearActor();
root.getCells().get(0).clearActor();
root.getCells().get(0).setActor(image1);
group.clear();
group.addActor(image4);
group.addActor(image2);
group.addActor(image3);
root.getCells().get(1).setActor(group);
return true;
}
});
root.getChildren().get(0).addListener(new InputListener(){
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
root.getCells().get(0).clearActor();
root.getCells().get(1).clearActor();
root.getCells().get(1).setActor(image4);
group.clear();
group.addActor(image1);
group.addActor(image2);
group.addActor(image3);
root.getCells().get(0).setActor(group);
return true;
}
});