问题:点击here查看我的地图在渲染时的样子。 this图片就是我想呈现的内容。我尝试用一层草和几朵花制作一张新的Tiled地图,当我尝试渲染时,根本没有任何东西出现。如何解决此问题以渲染我的整个Tiled地图?
任何帮助表示赞赏!
代码:
游戏课
private GameScreen screen;
@Override
public void create ()
{
setScreen(new GameScreen());
}
@Override
public void render ()
{
super.render();
screen.render(Gdx.graphics.getDeltaTime());
}
@Override
public void dispose ()
{
super.dispose();
screen.dispose();
}
@Override
public void resize(int width, int height)
{
super.resize(width, height);
screen.resize(width, height);
}
@Override
public void pause()
{
super.pause();
screen.pause();
}
@Override
public void resume()
{
super.resume();
screen.resume();
}
public void setScreen (GameScreen screen)
{
if (this.screen != null)
this.screen.hide();
this.screen = screen;
if (this.screen != null)
{
this.screen.show();
this.screen.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
}
GameScreen类
private TmxMapLoader mapLoader;
private TiledMap map;
private OrthogonalTiledMapRenderer mapRenderer;
private OrthographicCamera camera;
private FitViewport viewPort;
public GameScreen()
{
camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.setToOrtho(false);
camera.update();
viewPort = new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
viewPort.setScreenPosition((int) (Gdx.graphics.getWidth() * 0.5f), (int) (Gdx.graphics.getHeight() * 0.5f));
mapLoader = new TmxMapLoader();
map = mapLoader.load("maps/town.tmx");
mapRenderer = new OrthogonalTiledMapRenderer(map);
}
@Override
public void show()
{
}
public void input()
{
}
public void update(float delta)
{
input();
camera.update();
mapRenderer.setView(camera);
}
@Override
public void render(float delta)
{
update(delta);
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
mapRenderer.render();
}
@Override
public void resize(int width, int height)
{
viewPort.update(width, height);
}
@Override
public void pause()
{
}
@Override
public void resume()
{
}
@Override
public void hide()
{
}
@Override
public void dispose()
{
map.dispose();
mapRenderer.dispose();
}
答案 0 :(得分:0)
我相信问题是我的tileset png文件。该文件的分辨率为256x8100左右。我改为更合理的瓷砖组,根本没有任何问题。我希望遇到这个问题的其他任何人都会认为这是一个潜在的解决方案。 :)