I started to work in Phaser 3 with a previous background in programming in Unity and I can't figure out how to zoom the camera view. In Unity, I can change this value, to resize the camera view:

Unity camera Size

Then, everything in its view becomes bigger or smaller and it does not affect GUI elements, and the camera still fills up the full game window.

In Phaser I was trying to use those methods:

this.cameras.main.setSize(width,height) - it just resizes the camera making it smaller, and everything outside the camera becomes black

this.cameras.main.setViewport(x,y,width,height) - just as above, but x and y ads padding

this.cameras.main.setZoom(3) - the closest effect I want to achieve, but it zooms to the center of the scene, scales GUI elements and messes the camera bounds

I made an illustrative picture which can explain my problems better: enter image description here

So how can I change the size of the main camera, to fit the game window and not scale the GUI, keeping the camera bounds at the same time?


Your Answer

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

Browse other questions tagged or ask your own question.