add area destroy function
This commit is contained in:
parent
9f389e5232
commit
8ad931f33b
1 changed files with 12 additions and 0 deletions
12
obj/Area.lua
12
obj/Area.lua
|
|
@ -32,6 +32,18 @@ function Area:draw()
|
|||
for _, game_object in ipairs(self.game_objects) do game_object:draw() end
|
||||
end
|
||||
|
||||
---Destroys area
|
||||
function Area:destroy()
|
||||
for i = #self.game_objects, 1, -1 do
|
||||
local game_object = self.game_objects[i]
|
||||
game_object:kill()
|
||||
table.remove(self.game_objects, i)
|
||||
end
|
||||
self.game_objects = {}
|
||||
|
||||
if self.world then self.world = nil end
|
||||
end
|
||||
|
||||
---Adds game object to area
|
||||
---@param game_object_type string name of game object's class
|
||||
---@param x number|nil horizontal position
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue