add room destroy function
This commit is contained in:
parent
eb7ce44fa1
commit
8d49bc70e5
2 changed files with 7 additions and 0 deletions
1
main.lua
1
main.lua
|
|
@ -121,6 +121,7 @@ function gotoRoom(room_type, ...)
|
|||
if type(Class) ~= "table" and type(Class) ~= "function" then
|
||||
error("room '"..room_type.."' is not callable (got "..type(Class)..", does room return itself?)")
|
||||
end
|
||||
if current_room and current_room.destroy then current_room:destroy() end
|
||||
current_room = _G[room_type](...)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -46,4 +46,10 @@ function Room:canvasDraw()
|
|||
self.area:draw()
|
||||
end
|
||||
|
||||
---Destroys room
|
||||
function Room:destroy()
|
||||
self.area:destroy()
|
||||
self.area = nil
|
||||
end
|
||||
|
||||
return Room
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue