diff --git a/examples/gameplay/moveplayer/actors/parent.lua b/examples/gameplay/moveplayer/actors/parent.lua index 3069c61..cd03b5e 100644 --- a/examples/gameplay/moveplayer/actors/parent.lua +++ b/examples/gameplay/moveplayer/actors/parent.lua @@ -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 diff --git a/gamecore/modules/world/actors/actor2D.lua b/gamecore/modules/world/actors/actor2D.lua index 4879544..3fea1fd 100644 --- a/gamecore/modules/world/actors/actor2D.lua +++ b/gamecore/modules/world/actors/actor2D.lua @@ -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