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
|
if type(Class) ~= "table" and type(Class) ~= "function" then
|
||||||
error("room '"..room_type.."' is not callable (got "..type(Class)..", does room return itself?)")
|
error("room '"..room_type.."' is not callable (got "..type(Class)..", does room return itself?)")
|
||||||
end
|
end
|
||||||
|
if current_room and current_room.destroy then current_room:destroy() end
|
||||||
current_room = _G[room_type](...)
|
current_room = _G[room_type](...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,4 +46,10 @@ function Room:canvasDraw()
|
||||||
self.area:draw()
|
self.area:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Destroys room
|
||||||
|
function Room:destroy()
|
||||||
|
self.area:destroy()
|
||||||
|
self.area = nil
|
||||||
|
end
|
||||||
|
|
||||||
return Room
|
return Room
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue