i used shape to draw area of querry, but I found querry not work correctly, it only works when the object in the center area and querry not work with objects at the edge, sometime all is nothing
I once also got some unstable results with it, but it turned out I mixed the numbers and instead of checking bounding box, I was checking like a sand clock figure like, using switched values for one axis So recheck your number, queryAABB usually works quite decently, can't tell the same about RayCasting though
@ar2rsawseen default, coordinate origin of gideros is top left, so positionY little is higher
in Gideros Documentation:
(table) = b2.World:queryAABB(lowerx, lowery, upperx, uppery) Parameters: lowerx: (number) the lower x coordinate of the query box lowery: (number) the lower y coordinate of the query box upperx: (number) the upper x coordinate of the query box uppery: (number) the upper y coordinate of the query box
and in case it is same sand clock, shape will draw shapes such.
@DungDajHjep I think it it a language problem, lower means small, minimal and upper means, greater, maximal. As in lower bound and upper bound
So you can read it as:
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
Just try changing it and see if there is any differences
Comments
http://docs.giderosmobile.com/reference/physics/b2DebugDraw#b2.DebugDraw
I tried to create a body in within the area querry and I do not get it in the fixtures list. Seems querryAABB works very unstable.
When area of querying is larger more I get number of fixture less or nothing.
So recheck your number, queryAABB usually works quite decently, can't tell the same about RayCasting though
combo1 = {attackOffsetX = 10, attackOffsetY = 8, attackWidth = 60, attackHeight = 70} ,
combo2 = {attackOffsetX = 10, attackOffsetY = 8, attackWidth = 38, attackHeight = 36}
attackRect = combo1
local startX = self.posX + attackRect.attackOffsetX
local startY = self.posY + attackRect.attackOffsetY
if self.attackDir == -1 then
startX = self.posX- attackRect.attackOffsetX - attackRect.attackWidth
end
local fixtures = self.map.b2world:queryAABB(startX, startY, startX + attackRect.attackWidth, startY - attackRect.attackHeight)
--print(self.posX,self.posY,startX, startY, startX + attackRect.attackWidth, startY - attackRect.attackHeight)
--------------------
local shape = Shape.new()
shape:clear()
shape:beginPath()
shape:setFillStyle(Shape.SOLID, 0x9a5c78)
shape:moveTo(startX,startY)
shape:lineTo(startX + attackRect.attackWidth,startY)
shape:lineTo(startX + attackRect.attackWidth, startY - attackRect.attackHeight)
shape:lineTo(startX, startY - attackRect.attackHeight)
shape:endPath()
self.map:addChild(shape)
Timer.delayedCall(500,function()
shape:removeFromParent()
shape:clear()
shape = nil
end)
startY - attackRect.attackHeight ?
if it makes it lower than startY then you have the same problem as me.
in Gideros Documentation:
(table) = b2.World:queryAABB(lowerx, lowery, upperx, uppery)
Parameters:
lowerx: (number) the lower x coordinate of the query box
lowery: (number) the lower y coordinate of the query box
upperx: (number) the upper x coordinate of the query box
uppery: (number) the upper y coordinate of the query box
and in case it is same sand clock, shape will draw shapes such.
As in lower bound and upper bound
So you can read it as:
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
Just try changing it and see if there is any differences
Likes: DungDajHjep
Likes: DungDajHjep