MatchResult:getMiddleY()
返回匹配区域中心点的 Y 坐标。
描述
getMiddleY() 方法返回匹配区域的垂直中心位置(Y 坐标)。当您想要执行诸如点击匹配图像或文本的中心等操作时,此方法非常有用。
中心 Y 坐标的计算方式为:getY() + (getHeight() / 2)
签名
getMiddleY(): number
返回值
number - 匹配区域中心点的 Y 坐标(以像素为单位)。
示例
local result = Screen:find("button.png")
if result then
local centerX = result:getMiddleX()
local centerY = result:getMiddleY()
-- 点击匹配区域的中心
Screen:click(centerX, centerY)
end