Working with resolutions (also some bug with click_and_drag if used with custom render script)

Is there a way to make my game displayed pixel perfect? It may be critical if game has pixel art graphics. Tried some render samples and it seems that’s not what I am looking for. My initial resolution is 240x320, so I need only proportional scaling x2. I.e. 480x640, 640x980, 720x960, 960x1280 depending on game window size. I know already that working with resolutions in Defold is not that simple, so is this actually possible?

@britzl There is also some bug with cursor in this script if used with custrom render scripts. Is there a way to fix it?

You can try flappy bird game example. It is pixel, and contains complicated logic for scaling. If you need only proportional scaling , you should check aspect ration of screen, and then add some border in x or y, if aspect of screen is different then your. https://github.com/d954mas/defold-flappy-bird/blob/master/lib/screen_helper.lua

1 Like

Thank you. Your approach is really nice, results are predictable. But, actually, scaling works only in Defold redactor (windows and android builds also works well, I think macOS versions will be ok too). But HTML5 build doesn’t scale in browser :frowning: Hm… Seems that HTML5 build doesn’t support scaling of game window regardless of the render script.

2 Likes

You can change width and height in game project. =)

If you use a custom render script you need to translate screen coordinates to proper world coordinates. I’ve solved this in a generic way in my Orthographic Camera API where you can do camera.screen_to_world() and vice-versa. The provided render script also has multiple configurations for pixel perfect scaling.

2 Likes

Thank you britzl for your help. This extension It is really useful, as always. Without this and other extensions it would be really painful to use Defold for non-programmers such as me. :slight_smile: