#3312 closed defect (fixed)
[PATCH] Main-menu rear-most background layer shifts suddenly sideways
Reported by: | s0600204 | Owned by: | leper |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 19 |
Component: | Art & Animation | Keywords: | patch |
Cc: | sanderd17 | Patch: |
Description
To reproduce:
- Start 0AD, (windowed at minimum resolution shows it up well, but fullscreen/maximised will work)
- Watch the rear-most layer (the one with the hills)
- After about 26s, the hills 'jump' horizontally.
- If you wait a little longer, and the layers start scrolling the other way, the backdrop 'jumps' back.
The problem seems to be on line 62 of mainmenu.js
. What's written there would only work if the image loops/tiles every screen.right
pixels. If the line was changed to left -= w;
, it should work slightly better... except... the value of w
also appears to be incorrect.
w
is, as far as I can tell, the calculated scaled width of the layer. Except it's not calculated properly. The line assumes that the layer's sprite has an aspect ratio of 16:9. But the native size of all three layers is 2048x1024, an aspect ratio of 2:1.
The attached patch proposes a fix. (Yes, the patch still makes an assumption about the aspect ratio, but as far as I know there's no way to determine a sprite's original texture size via JS.)
Refs. #2993
Attachments (1)
Change History (8)
comment:1 by , 9 years ago
Keywords: | review patch added |
---|
comment:2 by , 9 years ago
Cc: | added |
---|---|
Summary: | Main-menu rear-most background layer shifts suddenly sideways → [PATCH] Main-menu rear-most background layer shifts suddenly sideways |
Sander, do you have some time to look into this?
comment:3 by , 9 years ago
I don't see why the change to 2:1 ratio is needed. w is just an estimated width of a single screen, so estimated at 16:9. It serves mainly to bring the characters on a certain screen, rather than putting a seam between them.
Apart from that, your patch is probably correct, and I didn't notice it because my screen was exactly 16:9, so screen.right matched w.
comment:4 by , 9 years ago
w
is also the amount of pixels subtracted from left
whenever the code thinks the left edge of the layer is to the right of the left edge of the screen.
If w
is too small or too large, then the jump when the layer edge crosses over and w
is no longer subtracted from left
is noticable.
comment:5 by , 9 years ago
I see. Using screen.right was indeed wrong there, but using w isn't right either, as w means something different there.
It would be better to just hard-code it to 2*h. Similar to line 67.
comment:7 by , 9 years ago
Keywords: | review removed |
---|
Thanks for the patch. Would be nicer to have a patch from the top level directory (that is paths start with binaries/....).
Musn't forget these...