I have 2 rectangles in my GUI, both of them have the same height - 2px. In the game, though they look like they have different heights, as far as I understand due to scaling (see screenshot attached). Is there any way to make them appear similar?
Make sure their X,Y positions are aligned to whole pixels.
Or use a 1x1 pixel texture with a bit of margin and extrude borders configured in the atlas. (Which you should anyway for batching reasons)
Thanks for the reply! X, Y positions are aligned to whole pixels, but I am afraid they might become floating point values when I scale the game.
I do use 1px texture with margin and extrude borders in atlas. One thing I also noticed if I scale the window up and down lines become similar, or sometimes bottom line becomes thicker then the top one or, if I scale down too much one of the lines disapears, and then after scaling more it appears again and another one disappears.
I created a sample project where I am able to reproduce the issue BTW https://github.com/iovorobiev/defold-scaling-lines
Yes, it’s tricky, you might want to listen to the window_resize
message sent to your render script, send a message to your GUI (or dispatch it with your favorite pub-sub solution), then in your GUI re-align it to whole pixels whenever the screen gets resized.
I will look into it, thanks a lot for your help