0
votes

I am drawing with libgdx and using OrthographicCamera. During render I draw a bit more than the screen can contain. As OrthographicCamera is always centred my camera moves quickly to the last primitive a draw. That's not what I need. So I want my camera to move slowly What I need is to draw a lot of squares they are in GameRoute.Level[] and to slowly "walk along them" with the camera

@Override
public void render () {
    Gdx.gl.glClearColor(0, 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);


    batch.begin();

    /*Drawing moving route*/
    int x = 0, y = 0;

    for(int i = 0; i < Route.Size; i++){
        batch.draw(GameRoute.Level[i].Step, x, y);

        if (GameRoute.Level[i].getDir() == 0) {
            x += 64;
        }
        if (GameRoute.Level[i].getDir() == 1) {
            y += 64;
        }
    }
    camera.position.set(0, 0, 0);

    GameRoute.ExpandLevel();


    batch.end();

}
1
You are setting the camera position to (0,0,0) but not updating the camera. Try using camera.update(); It sounds like you want the camera to move but your code says you want the camera to stay at 0,0,0. What are you trying to do?dfour
I am trying to create a game like Zig Zag, but in 2d. setting camera to (0.0.0) makes nothing even when I update the camera.CGA
What happens in a nutshell: the code quickly draws a lot of squares and the camera is shaking violently.CGA

1 Answers

0
votes

Solved, I remade the structure. Now instead of having a huge moving route, I am moving a small object Now future need in setting camera.