diff --git a/gamecore/modules/world/actors/utils/boxes/parent.lua b/gamecore/modules/world/actors/utils/boxes/parent.lua index 9b5e753..314cbab 100644 --- a/gamecore/modules/world/actors/utils/boxes/parent.lua +++ b/gamecore/modules/world/actors/utils/boxes/parent.lua @@ -23,7 +23,7 @@ local Box3D = Object:extend() -function Box3D:new(owner, w, h, d) +function Box3D:new(owner, w, h, d, isVisible) self.owner = owner self.world = owner.world self.cameras = self.world.cameras @@ -37,7 +37,12 @@ function Box3D:new(owner, w, h, d) self.shadowSources = {} self.needRedraw = false - self:setTexture() + self.isVisible = isVisible or true + + if (self.isVisible) then + self:setTexture() + end + self.shadows = love.graphics.newCanvas(self.w, self.h) self:register() @@ -138,12 +143,15 @@ function Box3D:redrawShadowCanvas() end function Box3D:draw(x, y, z) - love.graphics.setColor(0, 0, 0, 1) - if (self.haveLine) then - love.graphics.rectangle("line", x, (y-z) - (self.d), self.w, self.d + self.h) + if (self.isVisible) then + love.graphics.setColor(0, 0, 0, 1) + if (self.haveLine) then + love.graphics.rectangle("line", x, (y-z) - (self.d), self.w, self.d + self.h) + end + utils.graphics.resetColor() + love.graphics.draw(self.texture, x, (y-z) - (self.d)) end - utils.graphics.resetColor() - love.graphics.draw(self.texture, x, (y-z) - (self.d)) + if (self.shadows ~= nil) and (#self.shadowSources > 0) then love.graphics.draw(self.shadows, x, (y-z) - (self.d)) end