Difference between revisions of "B2.World:queryAABB"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(One intermediate revision by the same user not shown)
Line 6: Line 6:
 
=== <translate>Description</translate> ===
 
=== <translate>Description</translate> ===
 
Queries the world for all fixtures that potentially overlap the provided AABB.
 
Queries the world for all fixtures that potentially overlap the provided AABB.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
(table) = b2.World:queryAABB(minx,miny,maxx,maxy)
 
(table) = b2.World:queryAABB(minx,miny,maxx,maxy)
</source>
+
</syntaxhighlight>
  
 
=== <translate>Parameters</translate> ===
 
=== <translate>Parameters</translate> ===
Line 21: Line 21:
 
=== <translate>Examples</translate> ===
 
=== <translate>Examples</translate> ===
 
'''Query specific area for bodies'''
 
'''Query specific area for bodies'''
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
--get all fixtures in this area
 
--get all fixtures in this area
 
local fixtures = world:queryAABB(0, 0, 100, 10)
 
local fixtures = world:queryAABB(0, 0, 100, 10)
Line 31: Line 31:
 
end
 
end
 
end
 
end
</source>
+
</syntaxhighlight>
  
 
{{B2.World}}
 
{{B2.World}}

Latest revision as of 15:27, 13 July 2023


Available since: Gideros 2011.6
Class: b2.World

Description

Queries 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





LiquidFun