modules/world: make hitbox drawing part of actor
This commit is contained in:
parent
05f62a6842
commit
90458757e5
2 changed files with 15 additions and 1 deletions
|
@ -7,7 +7,7 @@ function Parent:new(world, type, x, y, w, h)
|
|||
end
|
||||
|
||||
function Parent:draw()
|
||||
utils.graphics.box(self.x, self.y, self.w, self.h)
|
||||
self:drawHitbox()
|
||||
end
|
||||
|
||||
return Parent
|
||||
|
|
|
@ -35,6 +35,8 @@ function Actor2D:new(world, type, x, y, w, h)
|
|||
|
||||
self:initKeys()
|
||||
self:register()
|
||||
|
||||
self:setDebugColor(1, 1, 1)
|
||||
end
|
||||
|
||||
function Actor2D:setManagers(world)
|
||||
|
@ -43,6 +45,13 @@ function Actor2D:setManagers(world)
|
|||
self.obj = world.obj
|
||||
end
|
||||
|
||||
function Actor2D:setDebugColor(r,g,b)
|
||||
self.debug = {}
|
||||
self.debug.r = r
|
||||
self.debug.g = g
|
||||
self.debug.b = b
|
||||
end
|
||||
|
||||
function Actor2D:initPhysics(x, y, w, h)
|
||||
self.x = x or 0
|
||||
self.y = y or 0
|
||||
|
@ -105,4 +114,9 @@ function Actor2D:draw()
|
|||
-- here will be update actions
|
||||
end
|
||||
|
||||
function Actor2D:drawHitbox()
|
||||
love.graphics.setColor(self.debug.r, self.debug.g, self.debug.b, 1)
|
||||
utils.graphics.box(self.x, self.y, self.w, self.h)
|
||||
end
|
||||
|
||||
return Actor2D
|
||||
|
|
Loading…
Reference in a new issue