类型 函数 库 physics.* 返回值 描述每次碰撞的表格数组 修订 版本 2024.3703 关键词 queryRegion, physics, 碰撞 另请参阅 physics.reflectRay()
此函数用于查找与轴对齐(非旋转)框相交的对象。该框由
返回的位置在内容空间中。
physics.queryRegion( upperLeftX, upperLeftY, lowerRightX, lowerRightY )
数字. 框区域的左上角 **x** 坐标。
数字. 框区域的左上角 **y** 坐标。
数字. 框区域的右下角 **x** 坐标。
数字. 框区域的右下角 **y** 坐标。
hits
将是一个与框区域碰撞的每个 显示对象 的数组。
local hits = physics.queryRegion( 10, 40, 100, 160 ) if ( hits ) then -- There's at least one hit print( "Hit count: " .. tostring( #hits ) ) -- Output the results for i,v in ipairs( hits ) do print( "Object position: ", v.x, v.y ) end else -- No hits in region end