add room destroy function

This commit is contained in:
yuki 2025-11-11 05:11:10 -03:00
parent eb7ce44fa1
commit 8d49bc70e5
2 changed files with 7 additions and 0 deletions

View file

@ -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

View file

@ -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