feat(world): add a way to check every hitbox collisions

This commit is contained in:
Kazhnuz 2019-06-23 15:53:51 +02:00
parent 89b2ffe483
commit cace01cf3a
2 changed files with 7 additions and 1 deletions

View file

@ -39,7 +39,7 @@ function Player:updateStart(dt)
end end
if (self.isPunching) then if (self.isPunching) then
--self:checkHitboxCollisions(self.punchName) self:checkHitboxesCollisions()
end end
if self.keys["start"].isPressed then if self.keys["start"].isPressed then

View file

@ -276,6 +276,12 @@ function Actor2D:addHitbox(name, type, ox, oy, w, h, isSolid)
end end
end end
function Actor2D:checkHitboxesCollisions(filter)
for k,v in pairs(self.hitboxes) do
self:checkHitboxCollisionsAtPoint(k, self.x, self.y, filter)
end
end
function Actor2D:checkHitboxCollisions(name, filter) function Actor2D:checkHitboxCollisions(name, filter)
self:checkHitboxCollisionsAtPoint(name, self.x, self.y, filter) self:checkHitboxCollisionsAtPoint(name, self.x, self.y, filter)
end end