Open labolado opened 5 months ago
When running a Solar2D HTML5 app in Google Chrome, if the page zoom level is set to a value other than 100%, the program cannot get correctly retrieve the actual width and height of the screen.
Test code:
local topInset, leftInset, bottomInset, rightInset = 0, 0, 0, 0 if (not isHarmonyOS) and (not isAndroidCard) then topInset, leftInset, bottomInset, rightInset = display.getSafeAreaInsets() end bottomInset = topInset local maxInset = math.max(leftInset, rightInset) leftInset = maxInset rightInset = maxInset _W = display.contentWidth _H = display.contentHeight _AW = display.actualContentWidth - (leftInset + rightInset) _AH = display.actualContentHeight - (topInset + bottomInset) _T = display.screenOriginY + topInset _B = _T + _AH _L = display.screenOriginX + leftInset _R = _L + _AW _RW = _R - _L _RH = _B - _T print(string.format( [[ _RW: %s, _RH: %s, _L: %s, _R: %s, _T: %s, _B: %s, topInset: %s, leftInset: %s, bottomInset: %s, rightInset: %s ]], _RW, _RH, _L, _R, _T, _B, topInset, leftInset, bottomInset, rightInset ))
When zoom level is 100%, the results are:
_RW: 2304, _RH: 1536, _L: -128, _R: 2176, _T: 0, _B: 1536, topInset: 0, leftInset: 0, bottomInset: 0, rightInset: 0
When zoom level is not 100%, the results are:
_RW: nan, _RH: nan, _L: nan, _R: nan, _T: nan, _B: nan, topInset: nan, leftInset: nan, bottomInset: nan, rightInset: nan
When running a Solar2D HTML5 app in Google Chrome, if the page zoom level is set to a value other than 100%, the program cannot get correctly retrieve the actual width and height of the screen.
Test code:
When zoom level is 100%, the results are:
When zoom level is not 100%, the results are: