|Attention||Topic was automatically imported from the old Question2Answer platform.|
My goal is to implement a constantly diminishing timebar on the top of the screen that fits all screen sizes. For example, the default window width of my game is 1280 px. If its on a wider screen such as 1600 px, the time bar should be longer and should diminish in a faster rate.
My attempt for the solution is to scale up the time bar with the ratio between the current viewport width to the default window width. Then adjust the position of the timebar by an offset which is calculated from the difference between the current viewport width and the default window width.
$ComboBar.rect_scale.x = $ComboBar.rect_scale.x*(get_viewport().size.x/1280) $ComboBar.rect_position.x = $ComboBar.rect_position.x - ((get_viewport().size.x-1280)/2)
The attempt works perfectly fine when playtested with different test window size on my Windows machine. However when I export to the Android device, the timebar was appeared as longer than the screen width. I tried to print the window size of my Android device which is 2400 px wide.
I tried printing the position of a notifier when exiting the screen and it shows
respectively, which I assume that the view port size of theA Android device does not match the actual view port size shown. The Android device used is Samsung Galaxy S20.
Does anyone face similar issue? Any help is much appreciated!