libgdx平铺贴图和纹理区域渲染

uujelgoq  于 2021-07-11  发布在  Java
关注(0)|答案(0)|浏览(231)

所以我尝试在我创建的平铺贴图上渲染一些纹理区域。问题是纹理区域在贴图下渲染。我还渲染了一个简单的纹理进行测试,结果是我所期望的。然而,那只是一个测试。我需要渲染纹理区域,因为我有很多东西要渲染。下面我将展示我的创建和渲染方法。纹理区域被注解掉了,但是当我运行它们时,问题是输出。

@Override
    public void create () {
        batch = new SpriteBatch();

        tiledMap = new TmxMapLoader().load("test 2.tmx");
        otmr = new OrthogonalTiledMapRenderer(tiledMap);
        //starts the map

        character = new Character(0,100,30,30);
        hearts = new Hearts(0,0,10,10);
        //sprites initializers

        //camera = new OrthographicCamera(800,800);
        //viewport = new StretchViewport(1920,1080,camera);
        //cam initializers KEEP THIS HERE

        camera = new OrthographicCamera();
        camera.setToOrtho(false,500,500);
        //cam initializers

        //texture2 = new Texture("raw_textures/player/static.png");
    }

    @Override
    public void render () {
        Gdx.gl.glClearColor(0, 0, 0, 0);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
        camera.update();
        otmr.setView(camera);
        otmr.render();
        //renders map

        batch.setProjectionMatrix(camera.combined);

        //camera.position.set(character.xpos + 20,character.ypos,0);
        //cam & clearer

        //TODO render sprtes on top of map

        batch.begin();
        //batch.draw(texture2,50,60);
        //character.draw(batch);
        //hearts.draw(batch);
        batch.end();
        //draws all sprites

    }
    ```

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题