diff options
-rw-r--r-- | not/Layer.lua | 4 | ||||
-rw-r--r-- | not/SceneManager.lua | 8 | ||||
-rw-r--r-- | not/World.lua | 4 |
3 files changed, 14 insertions, 2 deletions
diff --git a/not/Layer.lua b/not/Layer.lua index db16175..63c38ac 100644 --- a/not/Layer.lua +++ b/not/Layer.lua @@ -5,6 +5,10 @@ function Layer:new (width, height) self.canvas = love.graphics.newCanvas(width, height) end +function Layer:delete () + self.canvas = nil +end + --- Sets this layer as current canvas for drawing with love.graphics functions. -- @return old canvas used by love function Layer:setAsCanvas () diff --git a/not/SceneManager.lua b/not/SceneManager.lua index c076448..4f9edfd 100644 --- a/not/SceneManager.lua +++ b/not/SceneManager.lua @@ -9,7 +9,10 @@ end -- This function should be removed when multiple scenes will be handled properly by SceneManager and other things. function SceneManager:changeScene (scene) - table.remove(self.scenes, #self.scenes) + local removed = table.remove(self.scenes, #self.scenes) + if removed then + removed:delete() + end return self:addScene(scene) end @@ -20,7 +23,8 @@ end -- Not nice, not nice. function SceneManager:removeTopScene () - table.remove(self.scenes, #self.scenes) + local scene = table.remove(self.scenes, #self.scenes) + scene:delete() end function SceneManager:getAllScenes () diff --git a/not/World.lua b/not/World.lua index e8b847a..2774c92 100644 --- a/not/World.lua +++ b/not/World.lua @@ -49,7 +49,11 @@ function World:delete () for _,entity in pairs(self.entities) do entity:delete() end + for _,layer in pairs(self.layers) do + layer:delete() + end self.world:destroy() + collectgarbage() end --- Builds map using one of tables frin config files located in `config/maps/` directory. |