|
Post by AnkuLua on Dec 9, 2018 14:26:57 GMT
Current smart phones have many screen aspect ratios, from 16:10 to 21:9. How does the game handle the different aspect ratios? There are some fixed rules. We will talk one of those rules and teach you how to write scripts that running on different aspect ratios.
Basically, this type of games doesn't change the major icons on different screen ratios. For example, the Summoners War screenshots on 1280x720 and 1440x720 are  You can try the games on devices or emulators with different aspect ratios. It would be easier to try it on emulators. You can just set the emulator to different aspect ratios. For these games, we can just use following script to adjust the compare dimensions. function setupDimension(height) local deviceWidth = getRealScreenSize():getX() local deviceHeight= getRealScreenSize():getY() local widthOverHeight = deviceWidth / deviceHeight if (widthOverHeight > (16/9 + 0.1)) then local newDimension = widthOverHeight * height Settings:setCompareDimension(true, newDimension) print("new dimension = " .. newDimension) end end You should call this method after setting compare dimension to the width that the script is developed on. The parameter is the height that you develop the script. For example, if the script is developed in 1280x720. You should call the method by setupDimension(720). You may need to handle some region settings. Normally, it's ok to make the regions a little larger.
|
|
zouna
Contributors  
Posts: 109
|
Post by zouna on Dec 23, 2018 5:40:06 GMT
Hey AnkuLua, this would benefit all functions which use the image recognition to find the Location to click or check. I have to use some static click() function calls. If I understand this correctly, my way to click(location) would not adjust location with something like Location(x+newDimensionDifference,y+newDimensionDifference) right? But I think I could add that difference myself. Just want to make sure I'm not trying to write something that might already be supported.
|
|
|
Post by AnkuLua on Dec 23, 2018 7:45:23 GMT
Hey AnkuLua, this would benefit all functions which use the image recognition to find the Location to click or check. I have to use some static click() function calls. If I understand this correctly, my way to click(location) would not adjust location with something like Location(x+newDimensionDifference,y+newDimensionDifference) right? But I think I could add that difference myself. Just want to make sure I'm not trying to write something that might already be supported. No, this does not benefit Location().
|
|
|
Post by whatever on May 29, 2019 3:04:29 GMT
Hi Ankulua,
I followed this post to implement my code but it doesn't work. Basically, I developed on 1280x720 device & try to run the code on 1440x720 device.
all_screen = Region(0, 0, 1280, 720)
function isLayout(image)
result = regionFindAllNoFindException(all_screen, image)
for i, m in ipairs(result) do
if (m:getScore() > 0.7) then
return true, m
end
end
return false
end Settings:setScriptDimension(true, 1280)
Settings:setCompareDimension(true, 1280)
Settings:set('MinSimilarity', 0.8) setupDimension(720)
The isLayout function used to check if the input image is in the current screen or not. But it only works on 1280x720 device. Can you take a look & show me how to make it work please?
|
|
|
Post by AnkuLua on May 29, 2019 12:10:36 GMT
Hi Ankulua, I followed this post to implement my code but it doesn't work. Basically, I developed on 1280x720 device & try to run the code on 1440x720 device. all_screen = Region(0, 0, 1280, 720)
function isLayout(image)
result = regionFindAllNoFindException(all_screen, image)
for i, m in ipairs(result) do
if (m:getScore() > 0.7) then
return true, m
end
end
return false
end Settings:setScriptDimension(true, 1280)
Settings:setCompareDimension(true, 1280)
Settings:set('MinSimilarity', 0.8) setupDimension(720)
The isLayout function used to check if the input image is in the current screen or not. But it only works on 1280x720 device. Can you take a look & show me how to make it work please? As it said in the thread. Please share the screenshots of both 1280x720 and 1440x720. If the icons are the same, you can use the setupDimension() function. Otherwise, you need to observe the screenshots and find the rules.
|
|
|
Post by whatever on May 30, 2019 23:26:00 GMT
Thank man. I got it.
|
|
|
Post by bielsantoro on Dec 4, 2019 6:48:11 GMT
Is there any smart way to benefit all static functions such as Location(), Click() or should I add every time the diff between the old dimension and the new one ?
|
|
|
Post by AnkuLua on Dec 6, 2019 11:50:00 GMT
Is there any smart way to benefit all static functions such as Location(), Click() or should I add every time the diff between the old dimension and the new one ? if screen aspect ratio is the same, then you don’t need to modify any code
|
|
|
Post by AnkuLua on Dec 6, 2019 11:50:04 GMT
Is there any smart way to benefit all static functions such as Location(), Click() or should I add every time the diff between the old dimension and the new one ? if screen aspect ratio is the same, then you don’t need to modify any code
|
|