Type Function Library physics.* Return value Array of tables describing each hit Revision Release 2022.3683 Keywords queryRegion, physics, collision See also physics.reflectRay()
This function is used to find the objects that intersect with an axis-aligned (non-rotated) box. This box is defined by an
The positions returned are in content space.
physics.queryRegion( upperLeftX, upperLeftY, lowerRightX, lowerRightY )
Number. The upper-left x coordinate for the box region.
Number. The upper-left y coordinate for the box region.
Number. The lower-right x coordinate for the box region.
Number. The lower-right y coordinate for the box region.
hits
will be an array of each DisplayObject colliding with the box region.
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