Difference between revisions of "B2.World:queryAABB"
From GiderosMobile
Line 3: | Line 3: | ||
'''<translate>Available since</translate>:''' Gideros 2011.6<br/> | '''<translate>Available since</translate>:''' Gideros 2011.6<br/> | ||
'''<translate>Class</translate>:''' [[Special:MyLanguage/b2.World|b2.World]]<br/> | '''<translate>Class</translate>:''' [[Special:MyLanguage/b2.World|b2.World]]<br/> | ||
+ | |||
=== <translate>Description</translate> === | === <translate>Description</translate> === | ||
− | + | Queries the world for all fixtures that potentially overlap the provided AABB. | |
− | |||
− | |||
<source lang="lua"> | <source lang="lua"> | ||
(table) = b2.World:queryAABB(minx,miny,maxx,maxy) | (table) = b2.World:queryAABB(minx,miny,maxx,maxy) | ||
</source> | </source> | ||
+ | |||
=== <translate>Parameters</translate> === | === <translate>Parameters</translate> === | ||
'''minx''': (number) <translate>the minimal x coordinate of the query box</translate> <br/> | '''minx''': (number) <translate>the minimal x coordinate of the query box</translate> <br/> | ||
Line 15: | Line 15: | ||
'''maxx''': (number) <translate>the maximal x coordinate of the query box</translate> <br/> | '''maxx''': (number) <translate>the maximal x coordinate of the query box</translate> <br/> | ||
'''maxy''': (number) <translate>the maximal y coordinate of the query box</translate> <br/> | '''maxy''': (number) <translate>the maximal y coordinate of the query box</translate> <br/> | ||
+ | |||
=== <translate>Return values</translate> === | === <translate>Return values</translate> === | ||
'''<translate>Returns</translate>''' (table) <translate>Indexed array of fixtures that potentially overlaps the provided AABB</translate><br/> | '''<translate>Returns</translate>''' (table) <translate>Indexed array of fixtures that potentially overlaps the provided AABB</translate><br/> | ||
+ | |||
=== <translate>Examples</translate> === | === <translate>Examples</translate> === | ||
− | '''Query specific area for bodies''' | + | '''Query specific area for bodies''' |
− | <source lang="lua">--get all fixtures in this area | + | <source 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 27: | Line 30: | ||
local body = fixtures[i]:getBody() | local body = fixtures[i]:getBody() | ||
end | end | ||
− | end</source> | + | end |
+ | </source> | ||
+ | |||
+ | {{B2.World}} |
Revision as of 16:20, 18 February 2020
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