back to the docs
chapter 4 at Designing a 2D world | Manual | Castle Game Engine
This is usually a good idea — this way the visible area remains the same, regardless of your viewport size, and even regardless of whether you use UI scaling (and with what reference size UI scaling works). To do this, just set Viewport.Camera.Orthographic.Width
to a constant value, like 1600. You can also set Viewport.Camera.Orthographic.Height
, but you don’t have to — the other viewport size (left as 0) will be calculated automatically based on current viewport control aspect ratio.
As a newb i got it all wrong, so i consider that paragraph ambiguos.
regardless of your viewport size
while it is typically a relatively minor concern for games (they usually run full-screen, unless the yhave a floating resizable “portal” windows, like OpenTTS), it was an issue for me, as i was designing a smi-desktop app, working in a usual window, free to any resizing.
So, what would happen if the user freelly resizes the app’s window?
set .Width to a constant value
and i did it
the other viewport size (left as 0) will be calculated automatically based on current viewport control aspect ratio.
and so i let it as zero, because i wanted CGE to respect my aspect ratio. I do not want CGE to ignore the aspect ratio, no!!!
I was not wanting my app “squeezed” by changing its hosting windows aspect ratio!
The bad side effcect was whe nuser was changing the window’s height not width - the elements quickly fallen out of view.
Test shows, though, that is was not the case. CGE would not “squeeze” my worls if i set BOTH .Width and .Height
Okay, common sense says there can be three strategies when fixing both Width and Height:
- treat them as “minimum” hint, preserve aspect ratio, scale to match the lowest of the two
- treat them as “maximum” hint, preserve aspect ratio, scale to match the largest of the two
- treat them as exact order, mantain both Height and Width to be exactly as specified, ignore aspect ratio
Frankly, a newb can not be sure which of the strategies CGE implement, and the current wording suggests the last one! It seems to be documented inside https://castle-engine.io/apidoc-unstable/html/CastleCameras.TCastleOrthographic.html#Height - perhaps some text can be copied from there, so mere reading Designing a 2D world | Manual | Castle Game Engine would give immediately correct if shallow idea. And then newb to be suggested to look into .Width for more detailed description.