Trying to understand camera projections and game screen size

Hi,

I have a question about the camera projections and game screen size. I am using defold orthographic camera asset and have set my game window as 720 x 1280 in the game.project display settings.

To visualize this size in the editor, I always add a gui_node so that I can see the boundaries of my screen. I then placed 2 tiles at the top left and at the bottom right like so:

but when i play the game, these window sizes are not respected, this is what it looks like in the game:

I am using FIXED_ZOOM projection with a zoom of 1.

I expect the game to open and play in a 720 x 1280 window and see my objects placed exactly where I placed them in the editor, but that does not appear to be the case

if I use FIXED_AUTO projection, the window looks like this:

the tiles are still not in the right positions and the blue tower should not be visible

The camera gameobject position is at the centre of the screen i.e. 360 x 640

Understanding this will really help me in my level design as I design a map in Tiled according to my display resolution but when I import it into Defold, the map does not look like it does in Tiled due to the above reasons.

1 Like

a very patient bump. :slight_smile:

1 Like

It doesn’t look like the aspect ratio of the window is correct. In the screenshot it looks like the window is much wider. Does the window fill the entire screen or do you have room below the window?

on my screen? no there appears to be no room above or below, I have to move the window to see the edges

Ok, so your screen is unable to show a 1280 pixel high window, but it can fit 720 horizontally. This means that you will have a different aspect ratio, which explains why you are seeing more content to the left and right.

Thanks, but this does not appear to be the reason.

To test this, I changed my game display to 360 x 640 and repeated the same test by placing the tiles on the edges of the UI boundary as seen below:

As can be seen, the tiles are on the edges of 360 and 640 i.e. the display size of my game.

Leaving the camera settings at FIXED_ZOOM and ZOOM of 1, I get the following game window:

With this resolution, I have lots of space on my screen and it still comes out like this.

Would appreciate some help in understanding this .

With these changes, I expect the game to open and play in a 360x 640 window and see my objects placed exactly where I placed them in the editor, but that does not appear to be the case

Are you able to share a minimal project?

It looks like the window opens at twice the size set in game.project?

I created a new project to demonstrate this and its generating the same game window. Game project attached.

for-github-issue.zip (308.9 KB)

sorry for another bump, but i still cant figure out why my camera is the way it is…

was the game project attached of any help to demonstrate my problem?

Not exactly, but you have moved your camera to the wrong position. Your camera game object is positioned at x: 159, y: 260, which is not the center of the GUI (360x640).
If you set the position to the center(180x320), it will look correct.

Screenshot 2025-01-21 at 23.53.54

1 Like

thanks for this, as this got me to test my project on another machine.

So, whats strange is that when I open this project on my msi laptop, screen resolution: 1920 x 1080, then this look normal and as expected, and moving the camera to the correct position gives me the game window as your screenshot.

but when I open the same project on my surface pro, screen resolution: 2736 x 1824, then the game window looks like the very zoomed out version from my earlier screenshots.

this was driving me nuts and was very near to giving up on defold and move back to unity for my side project.

is this an engine bug? should I report it on github? what other info would be required for the report in addition to my game project?

and how do I fix the view on my surface pro to look normal and not super zoomed out?

My guess is that your surface pro has something similar to the Apple retina screen where a pixel actual consist of four smaller pixels. When you say “super zoomed out” I assume you see exactly twice as much content. Is my assumption correct?

correct, looks like below:

image_2025-01-24_085052127

Ok, thanks. Defold-Orthographic should try to figure this out and handle it correctly. Could you please create a bug report in the repository and I’ll make sure to look into it this weekend?

1 Like