Hi i am learning libGDX these days, I followed this example, and I read this wiki

I dont really understand these line of code after adding viewport

public void resize(int width, int height) {
super.resize(width, height);
extendViewport.update(width, height);

And rendering


banana.setPosition(0, 0);

banana.setPosition(100, 100);


Looking at the example, they still draw the banana in bottom-left of screen, I mean the (0, 0) point still in bottom-left of screen enter image description here

While in my code, I think it changed the coordinate to center of screen, (0, 0) now is center of screen.

enter image description here

I am not clearly understand about this.


When you call ExtendViewport#update(), you're not passing the third parameter (like the tutorial does), so it is centering the camera on 0,0 instead of positioning the camera so that 0,0 is in the lower-right corner.

If you change your call to be extendViewport.update(width, height, false) it should remedy the issue.

  • \$\begingroup\$ yes, you're right. I fixed it \$\endgroup\$ – Tai Tran Dec 20 '16 at 1:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.