0

我通过相机视口将瓷砖区域复制到剪贴板。从那里我将剪贴板粘贴回某个区域的地图。像这样:

public void render(float delta) {

        if(camera.frustum.pointInFrustum(0, 0, 0)) {
            camera.position.x = layer.getWidth() * layer.getTileWidth() / 2;
            camera.position.y = Gdx.graphics.getHeight();
            camera.frustum.boundsInFrustum(0, 1280, 0, Gdx.graphics.getWidth() / 2 - scrollSpeed, Gdx.graphics.getHeight() / 2 - scrollSpeed, 0);
            clipboard = TileMapCopier.copyRegion(layer, 0, 0, (int) camera.viewportWidth, (int) camera.viewportHeight);
            TileMapCopier.pasteRegion(layer, clipboard, 0, layer.getHeight() / 2);
        }
public TiledMapTile[][] copyRegion(TiledMapTileLayer layer, int x, int y, int width, int height) {
    TiledMapTile[][] region = new TiledMapTile[width][height];

    for (int ix = x; ix < x + width; ix++)
        for (int iy = y; iy < y + height; iy++) {
            Cell cell = layer.getCell(ix, iy);
            if(cell == null)
                continue;

            region[ix - x][iy - y] = cell.getTile();

        }

    return region;
}

public void pasteRegion(TiledMapTileLayer layer, TiledMapTile[][] region, int x, int y) {
    for (int ix = x; ix < x + region.length; ix++)
        for (int iy = y; iy < y + region[ix].length; iy++) {
            Cell cell = layer.getCell(ix, iy);
            if(cell == null) {
                Gdx.app.debug(TileMapCopier.class.getSimpleName(), "pasteRegion: skipped [" + ix + ";" + iy + "]");
                continue;
            }
            cell.setTile(region[ix - x][iy - y]);
        }
}

在转换过程中,它会停止大约 5 秒,然后发送一堆蓝色 logCAT 消息,然后继续运行。消息如下所示:

05-20 23:55:31.669: D/dalvikvm(1655): GC_CONCURRENT freed 460K, 6% free 11776K/12487K, paused 12ms+23ms, total 60ms

当我更改复制方法中的宽度和高度以复制视口宽度和高度的宽度和高度(这是它需要的)时,这才开始这样做。但是,当它被设置为图层的宽度和高度时,它并没有这样做。

请帮忙?可能是什么原因?我应该怎么知道?

4

0 回答 0