fix(hitbox): fix position computation
This commit is contained in:
parent
553d7feab4
commit
ae089b58a5
1 changed files with 16 additions and 2 deletions
|
@ -73,11 +73,11 @@ function Hitbox:applyScale(scale)
|
||||||
local sy = scale.y or 1
|
local sy = scale.y or 1
|
||||||
|
|
||||||
if (sx < 0) then
|
if (sx < 0) then
|
||||||
self.position.x = self.owner.dimensions.w - self.position.x - self.dimensions.w
|
self.relativePosition.x = self.owner.dimensions.w - self.relativePosition.x - self.dimensions.w
|
||||||
end
|
end
|
||||||
|
|
||||||
if (sy < 0) then
|
if (sy < 0) then
|
||||||
self.position.y = self.owner.dimensions.h - self.position.y - self.dimensions.h
|
self.relativePosition.y = self.owner.dimensions.h - self.relativePosition.y - self.dimensions.h
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -132,4 +132,18 @@ function Hitbox:checkCollisionAtPoint(destination, filter)
|
||||||
return new, cols, colNumber
|
return new, cols, colNumber
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- DEBUG FUNCTIONS
|
||||||
|
-- Draw debug
|
||||||
|
|
||||||
|
function Hitbox:draw()
|
||||||
|
local position = self:getPosition()
|
||||||
|
local dimensions = self.dimensions
|
||||||
|
local r, g, b = love.graphics.getColor()
|
||||||
|
love.graphics.setColor(0, 0, 0, 0.5)
|
||||||
|
love.graphics.rectangle("fill", math.floor(position.x), math.floor(position.y), dimensions.w, dimensions.h)
|
||||||
|
love.graphics.setColor(0, 0, 0, 1)
|
||||||
|
love.graphics.rectangle("line", math.floor(position.x), math.floor(position.y), dimensions.w, dimensions.h)
|
||||||
|
love.graphics.setColor(r, g, b)
|
||||||
|
end
|
||||||
|
|
||||||
return Hitbox
|
return Hitbox
|
||||||
|
|
Loading…
Add table
Reference in a new issue