Difference between revisions of "B2.World:queryAABB"

From GiderosMobile
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''Available since:''' Gideros 2011.6<br/>
+
<languages />
=== Description ===
+
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
<br />
+
'''<translate>Class</translate>:''' [[Special:MyLanguage/b2.World|b2.World]]<br/>
Query the world for all fixtures that potentially overlap the provided AABB.<br />
+
 
<br />
+
=== <translate>Description</translate> ===
<source lang="lua">
+
Queries the world for all fixtures that potentially overlap the provided AABB.
 +
<syntaxhighlight lang="lua">
 
(table) = b2.World:queryAABB(minx,miny,maxx,maxy)
 
(table) = b2.World:queryAABB(minx,miny,maxx,maxy)
</source>
+
</syntaxhighlight>
=== Parameters ===
+
 
'''minx''': (number) the minimal x coordinate of the query box <br/>
+
=== <translate>Parameters</translate> ===
'''miny''': (number) the minimal y coordinate of the query box <br/>
+
'''minx''': (number) <translate>the minimal x coordinate of the query box</translate> <br/>
'''maxx''': (number) the maximal x coordinate of the query box <br/>
+
'''miny''': (number) <translate>the minimal y coordinate of the query box</translate> <br/>
'''maxy''': (number) the maximal y coordinate of the query box <br/>
+
'''maxx''': (number) <translate>the maximal x coordinate of the query box</translate> <br/>
=== Return values ===
+
'''maxy''': (number) <translate>the maximal y coordinate of the query box</translate> <br/>
'''Returns''' (table) Indexed array of fixtures that potentially overlaps the provided AABB<br/>
+
 
=== Examples ===
+
=== <translate>Return values</translate> ===
'''Query specific area for bodies'''<br/>
+
'''<translate>Returns</translate>''' (table) <translate>Indexed array of fixtures that potentially overlaps the provided AABB</translate><br/>
<source lang="lua">--get all fixtures in this area
+
 
 +
=== <translate>Examples</translate> ===
 +
'''Query specific area for bodies'''
 +
<syntaxhighlight lang="lua">
 +
--get all fixtures in this area
 
local fixtures = world:queryAABB(0, 0, 100, 10)
 
local fixtures = world:queryAABB(0, 0, 100, 10)
 
--check if there are any fixture
 
--check if there are any fixture
Line 25: Line 30:
 
local body = fixtures[i]:getBody()
 
local body = fixtures[i]:getBody()
 
end
 
end
end</source>
+
end
 +
</syntaxhighlight>
 +
 
 +
{{B2.World}}

Latest revision as of 14: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