One way to handle multiple screen resolutions is to set the mode
and aspect
of the project settings to (general -> display -> window
) to 2d
and keep
, which will make the screen aspect ratio the same across different resolutions. That should work around issues where the difference in screen size changes the viewport.
For the sprites themselves, I dunno. I think what I would try initially is to load the different sprite sizes through GDScript in the _ready
function for each RigidBody2D node, storing the expected scale and texture in a list/dictionary that is predefined within the script. Something like this (untested pseudo GDScript code):
var sprites = {
"4K": {
"Sprite_01": [preload("res://path_to_hd_image.png"), Vector2(0.2, 0.2)]
}
"HD": {
"Sprite_01": [preload("res://path_to_sd_image.png"), Vector2(1, 1)]
}
}
func _ready():
var resolution = "HD"
var sprite_name = "Sprite_01"
if (get_tree().root.size.x > 1920):
resolution = "4K"
get_node("Sprite").texture = sprites[resolution][sprite_name ][0]
get_node("Sprite").scale = sprites[resolution][sprite_name ][1]
Or another way you could do it is instance different scenes based on the resolution. You'd need to write code that checks the screen resolution and based on the resolution, instances the scene with the correct sprite(s). This would require more scenes though, so it might not be worth it.
Finally, you could just use the high resolution sprites everywhere, since at HD it will just render the textures at a lower resolution. This would raise the performance requirements of your game a bit, but the ease of development might be worth it.
Those are just a few ways I might go about tackling the issue if I was developing for both HD and 4K. There might be better and easier ways of handling it, but hopefully the above is of some help :smile: