feat(world): add a function to reset world
This commit is contained in:
parent
fb35eca0fa
commit
a227bbb033
1 changed files with 15 additions and 3 deletions
|
@ -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
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue