Proper Resolution Setting in Defold

I am coming from other game engines and used to handle resolution scaling once and not worrying it for ever again. My implementation includes to stretch the set resolution (for example 320x180) by hole factor for given display space and cover remaining area with black bars.

This implementation works perfectly for most of the times but I do not know how to implement it in Defold in default ways. Is there a way or a custom implementation out there that can be done easily. I must also mention that it must work with camera component.

You can use the built-in camera and check the Orthographic Projection checkbox and set a fixed Orthographic Zoom:

You can also calculate the zoom on the fly based on the display width and height set in game.project and the actual window width:

-- get the display size set in game.project
local display_width = sys.get_config_int("display.width")
local display_height = sys.get_config_int("display.height")

-- get the actual display size
local current_width, current_height = window.get_size()
1 Like

How will ı use this data to implement my desired outcome? Even if ı use the correct level of zooming, it will not produce black bars according to the original resolution, will it?

If you want to see black bars I suggest you use Rendercam

Personally I add blackbars as GUI elements so that I don’t have to deal with too complex coordinate conversions.

This is one thing that Defold will not do for you (mouse to screen or world conversions) and why a camera module is recommended.

1 Like

It says that this library is no longer maintained and Defold refuses to fetch this library, what may ı do?

Do you get an error? Can you fetch other libraries? Which dependency URL are you using?

I used this link to fetch the library and it says:

image

Try pointing to the zip file

https://github.com/rgrams/rendercam/archive/1.0.3.zip

1 Like

This works, thanks. However, would this affect anything inside the engine and does it convert screen to world coordinates?

Yes: https://github.com/rgrams/rendercam#transform-functions