feat(boxes): add a way to make basic boxes invisible
This commit is contained in:
parent
3e26d9a769
commit
7d65359230
1 changed files with 15 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue