Difference between revisions of "B2.World:queryAABB"

From GiderosMobile
Line 2: Line 2:
 
'''Available since:''' Gideros 2011.6<br/>
 
'''Available since:''' Gideros 2011.6<br/>
 
=== Description ===
 
=== Description ===
<br />
+
<translate><br />
 
Query the world for all fixtures that potentially overlap the provided AABB.<br />
 
Query the world for all fixtures that potentially overlap the provided AABB.<br />
<br />
+
<br /></translate>
 
<source lang="lua">
 
<source lang="lua">
 
(table) = b2.World:queryAABB(minx,miny,maxx,maxy)
 
(table) = b2.World:queryAABB(minx,miny,maxx,maxy)
 
</source>
 
</source>
 
=== Parameters ===
 
=== Parameters ===
'''minx''': (number) the minimal x coordinate of the query box <br/>
+
'''minx''': (number) <translate>the minimal x coordinate of the query box</translate> <br/>
'''miny''': (number) the minimal y coordinate of the query box <br/>
+
'''miny''': (number) <translate>the minimal y coordinate of the query box</translate> <br/>
'''maxx''': (number) the maximal x coordinate of the query box <br/>
+
'''maxx''': (number) <translate>the maximal x coordinate of the query box</translate> <br/>
'''maxy''': (number) the maximal y coordinate of the query box <br/>
+
'''maxy''': (number) <translate>the maximal y coordinate of the query box</translate> <br/>
 
=== Return values ===
 
=== Return values ===
'''Returns''' (table) Indexed array of fixtures that potentially overlaps the provided AABB<br/>
+
'''Returns''' (table) <translate>Indexed array of fixtures that potentially overlaps the provided AABB</translate><br/>
 
=== Examples ===
 
=== Examples ===
 
'''Query specific area for bodies'''<br/>
 
'''Query specific area for bodies'''<br/>

Revision as of 14:32, 23 August 2018

Available since: Gideros 2011.6

Description


Query the world for all fixtures that potentially overlap the provided AABB.

(table) = b2.World:queryAABB(minx,miny,maxx,maxy)

Parameters

minx: (number) the minimal x coordinate of the query box
miny: (number) the minimal y coordinate of the query box
maxx: (number) the maximal x coordinate of the query box
maxy: (number) the maximal y coordinate of the query box

Return values

Returns (table) Indexed array of fixtures that potentially overlaps the provided AABB

Examples

Query specific area for bodies

--get all fixtures in this area
local fixtures = world:queryAABB(0, 0, 100, 10)
--check if there are any fixture
if #fixtures > 0 then
	for i = 1, #fixtures do
		--getting body of fixture
		local body = fixtures[i]:getBody()
	end
end