Skip to content Skip to sidebar Skip to footer

Libgdx Fixed Point After Camera.rotatearound

Good night friends. I'm having trouble drawing a fixed point on the screen when the screen is rotated. I used the method 'rotateAround' from the position of the player. It seems to

Solution 1:

  1. It can be result of rounding because its moving a pixel.
  2. You can calculate rotation from the player but its not necessary.
  3. Of course you can use multiple cameras in your game and you should also in this case.

Its few screenshot from my old projects that i used multiple cameras enter image description hereenter image description here

As you can see you can even use different type of cameras like ortho and perspective both 2D and 3D.

Just create new camera like first one and change projection matrix

camrotate = newOrthographicCamera(540, 960);
//...
camfixed =  newOrthographicCamera(540, 960);
//...

And in render method

batch.setProjectionMatrix(camrotate.combined);
batch.begin();
//draw in camrotate now//...//...
batch.end();

batch.setProjectionMatrix(camfixed.combined);
batch.begin();
//draw fixed elements now//...//...   
batch.end();
//add one more camera if you need

Edit: Change projection matrix outside of batch.begin()/end() otherwise the current batch will flushed.

Post a Comment for "Libgdx Fixed Point After Camera.rotatearound"