Libgdx从单元格中删除和添加图像

Libgdx从单元格中删除和添加图像,libgdx,scene2d,Libgdx,Scene2d,我有这张桌子: 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()); 我

我有这张桌子:

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时,image1并没有添加到表中,而是添加到右屏幕上,而点击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;
        }
    });

就我个人而言,我会为每个表单元格设置一个侦听器,清除包含“image1”的单元格,然后在单击的单元格中分配图像。比如:

table.getChildren().get(0).addListener(new ClickListener(  // .get(0-3)
   Cell<Table> cell = table.getCell(image1);
   cell.clearActor();
   table.getCells().get(0).setActor(image1);               // .get(0-3)
));
table.getChildren().get(0).addListener(新建ClickListener(//.get(0-3))
Cell Cell=table.getCell(image1);
cell.clearActor();
table.getCells().get(0.setActor(image1);/.get(0-3)
));