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