Im copying a region of tiles by camera viewport to a clipboard. From there I am pasting the clipboard back to the map in a certain area. Like so:
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]);
}
}
During the transition, it stops for about 5 seconds, spams a bunch of blue logCAT messages and then keeps going. The messages look like this:
05-20 23:55:31.669: D/dalvikvm(1655): GC_CONCURRENT freed 460K, 6% free 11776K/12487K, paused 12ms+23ms, total 60ms
This only started doing it when I changed the width and height in the copy method to copy that of the viewports width and height(which is what it needs to be). It didnt do this when it was set for the layers width and height though.
Help please? What could be the reason? How am I supposed to know?