Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java libgdx camera.position.set导致撕裂_Java_Libgdx - Fatal编程技术网

Java libgdx camera.position.set导致撕裂

Java libgdx camera.position.set导致撕裂,java,libgdx,Java,Libgdx,我正在使用libgdx,如果我不尝试设置相机的位置,我的游戏渲染效果非常好。但如果我只添加这一行代码:camera.position.set(0f,0f,0f),它会在我的所有精灵上显示白线 之前: 添加一行代码后:camera.position.set(0f,0f,0f) 这些图像是随机地图,因此布局不同。唯一改变的是白线。摄影机确实会转到位置(0,0,0)。 这可能是什么原因造成的?它基本上是在我的精灵顶部添加一个白色像素。我有一个512x512瓷砖表,其中有64x64瓷砖。这是相关代码

我正在使用libgdx,如果我不尝试设置相机的位置,我的游戏渲染效果非常好。但如果我只添加这一行代码:camera.position.set(0f,0f,0f),它会在我的所有精灵上显示白线

之前:

添加一行代码后:camera.position.set(0f,0f,0f)

这些图像是随机地图,因此布局不同。唯一改变的是白线。摄影机确实会转到位置(0,0,0)。 这可能是什么原因造成的?它基本上是在我的精灵顶部添加一个白色像素。我有一个512x512瓷砖表,其中有64x64瓷砖。这是相关代码

屏幕类内部:

@Override
public void show() 
{
    float w = Gdx.graphics.getWidth();
    float h = Gdx.graphics.getHeight();

    this.camera = new OrthographicCamera(w, h);

    this.camera.setToOrtho(true, w, h);
    this.stage.setCamera(this.camera);
    camera.update();

    this.input = new InputHandler(this.camera);
    Gdx.input.setInputProcessor(this.input);

    dungeon = new Dungeon(DungeonGenerator.generateDungeonMap());

    renderer = new OrthogonalTiledMapRenderer(dungeon);

    this.player = new Player(dungeon);
    this.stage.addActor(this.player);

    camera.position.set(0f, 0f, 0f);

}

@Override
public void render(float delta) 
{

       Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
       Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    camera.update();

    renderer.setView(camera);
    renderer.render();

    batch.begin();
    font.draw(batch, "FPS: " + Gdx.graphics.getFramesPerSecond(), 10, 20); 
    font.draw(batch, "camera: " + camera.position, 10, 50); 
    font.draw(batch, "Stage:" + this.stage.getCamera().position, 10, 80);
    batch.end();

    //update and render stage actors
    stage.act(delta);
    stage.draw();



}

我想出来了。这个问题是由于我的精灵片有白色背景造成的。对精灵表进行一些更改后,我必须在不隐藏白色背景的情况下导出该表。我刚刚将alpha背景添加回精灵表,它再次正常工作。

这可能适用,谢谢。我刚读过。我现在正在尝试这个解决方案,但我不认为这是同一个问题。我使用batch.begin()和batch.end()尝试了不同的方法,就像链接中的解决方案一样,但不起作用