feat(world): add a function to reset world

This commit is contained in:
Kazhnuz 2019-06-16 16:33:29 +02:00
parent fb35eca0fa
commit a227bbb033

View file

@ -35,14 +35,16 @@ local PADDING_VALUE = 10/100
-- All functions to init the world and the map -- All functions to init the world and the map
function BaseWorld:new(scene, actorlist, mapfile) function BaseWorld:new(scene, actorlist, mapfile)
self.scene = scene self.scene = scene
self.actorlist = actorlist
self.mapfile = mapfile
self.cameras = CameraSystem(self) self.cameras = CameraSystem(self)
self:initActors() self:initActors()
self:initPlayers() self:initPlayers()
self:setActorList(actorlist) self:setActorList(self.actorlist)
self:initMap(mapfile) self:initMap(self.mapfile)
self:setGravity() self:setGravity()
self:register() self:register()
@ -79,6 +81,16 @@ function BaseWorld:register()
self.scene:registerWorld(self) self.scene:registerWorld(self)
end end
function BaseWorld:reset()
self:initActors()
self:initPlayers()
self:initMap(self.mapfile)
self.cameras:initViews()
collectgarbage()
self:loadMap()
end
-- ACTOR MANAGEMENT FUNCTIONS -- ACTOR MANAGEMENT FUNCTIONS
-- Basic function to handle actors -- Basic function to handle actors