수준 편집기에서 만든 PNG 파일을 만들 때 비슷한 문제가 발생했습니다. 레벨은 제작자가 배치 한 타일로 만들어지며 전체 레벨은 게임에 사용되는 .png 파일로 저장됩니다.
해결 방법 P.T. 설명합니다. 같은 문제에 부딪 치는 다른 사람들에게 유용하기를 바랍니다.
응용 프로그램 구성에서 : cfg.useGL20 = true; GL20은
public boolean exportLevel(){
//width and height in pixels
int width = (int)lba.getPrefWidth();
int height = (int)lba.getPrefHeight();
//Create a SpriteBatch to handle the drawing.
SpriteBatch sb = new SpriteBatch();
//Set the projection matrix for the SpriteBatch.
Matrix4 projectionMatrix = new Matrix4();
//because Pixmap has its origin on the topleft and everything else in LibGDX has the origin left bottom
//we flip the projection matrix on y and move it -height. So it will end up side up in the .png
projectionMatrix.setToOrtho2D(0, -height, width, height).scale(1,-1,1);
//Set the projection matrix on the SpriteBatch
sb.setProjectionMatrix(projectionMatrix);
//Create a frame buffer.
FrameBuffer fb = new FrameBuffer(Pixmap.Format.RGBA8888, width, height, false);
//Call begin(). So all next drawing will go to the new FrameBuffer.
fb.begin();
//Set up the SpriteBatch for drawing.
sb.begin();
//Draw all the tiles.
BuildTileActor[][] btada = lba.getTiles();
for(BuildTileActor[] btaa: btada){
for(BuildTileActor bta: btaa){
bta.drawTileOnly(sb);
}
}
//End drawing on the SpriteBatch. This will flush() any sprites remaining to be drawn as well.
sb.end();
//Then retrieve the Pixmap from the buffer.
Pixmap pm = ScreenUtils.getFrameBufferPixmap(0, 0, width, height);
//Close the FrameBuffer. Rendering will resume to the normal buffer.
fb.end();
//Save the pixmap as png to the disk.
FileHandle levelTexture = Gdx.files.local("levelTexture.png");
PixmapIO.writePNG(levelTexture, pm);
//Dispose of the resources.
fb.dispose();
sb.dispose();
주 프레임 버퍼를 구축 할 수 있도록 필요합니다 그래서이이 작업을 수행 할 수있는 산뜻한 방법이 될 수 없습니다 LibGDX에 새로운 오전.
텍스쳐는 간단한 페인트와 같은 인터페이스로 응용 프로그램 내에서 사용자가 생성하므로 사용자가 직접 데이터를 가지고 있지 않습니다. 그러나 완벽한 질감을 생성하는 데 사용하는 FrameBuffer에서 정보를 추출 할 수 있다면 화면에 그려지는 기본 FrameBuffer에서만이 작업을 수행 할 수 있다는 인상하에있었습니다. 제 경우에는 텍스처가 화면의 해상도를 초과 할 가능성이 있으므로이 경로를 따라 이미지가 잘 리거나 왜곡됩니다. 안타깝게도 Pixmap 자체를 드로잉에 사용하는 것도 옵션이 아닙니다. – Shamrock