除非使用平铺地图在libgdx中调整大小,否则屏幕不会渲染

时间:2016-02-21 14:41:14

标签: java android libgdx tiled

这一切都很好,然后我尝试在Android上运行它,这开始发生了。我做了一段时间,然后想了想,好吧,让我们回到光秃秃的骨头,看看我能不能解决它,没有这样的运气。我有主屏幕和介绍屏幕,渲染和正常工作,我一直在加载资产。当我进入游戏屏幕时,它会被清除,当我调整大小时,地图会显示出来。请看一看并告诉我出了什么问题。

public class GameScreen extends ScreenAdapter {    
    private Viewport viewport;
    private OrthographicCamera camera;

    private SpriteBatch batch;

    private TiledMap tiledMap;
    private OrthogonalTiledMapRenderer orthogonalTiledMapRenderer;

    private HowlersPlatform game;

    public GameScreen(HowlersPlatform game){
        this.game = game;
    }
    @Override
    public void show(){
        super.show();

        camera = new OrthographicCamera();
        viewport = new FitViewport(Constants.WORLD_WIDTH, Constants.WORLD_HEIGHT, camera);
        viewport.apply(true);

        batch = new SpriteBatch();
        tiledMap = Assets.map; // AssetsClass.instance.maps.themap;
        orthogonalTiledMapRenderer = new OrthogonalTiledMapRenderer(tiledMap,batch);
        orthogonalTiledMapRenderer.setView(camera);
    }

    @Override
    public void render(float delta){
        super.render(delta);
        update(delta);
        clearScreen();
        draw();    
    }

    private void clearScreen() {
        Gdx.gl.glClearColor(Color.TEAL.r, Color.TEAL.g, Color.TEAL.b, Color.TEAL.a);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    }

    public void draw(){    
        batch.setProjectionMatrix(camera.projection);
        batch.setTransformMatrix(camera.view);

        orthogonalTiledMapRenderer.render();    
    }

    public void update(float delta){    
    }    
}

0 个答案:

没有答案