modules/world: automatize multiple character handling
This commit is contained in:
parent
767fddadfa
commit
c41930fca4
1 changed files with 8 additions and 1 deletions
|
@ -144,6 +144,11 @@ end
|
||||||
|
|
||||||
function BaseWorld:initPlayers()
|
function BaseWorld:initPlayers()
|
||||||
self.players = {}
|
self.players = {}
|
||||||
|
self.playerNumber = 1
|
||||||
|
end
|
||||||
|
|
||||||
|
function BaseWorld:setPlayerNumber(playerNumber)
|
||||||
|
self.playerNumber = playerNumber or 1
|
||||||
end
|
end
|
||||||
|
|
||||||
function BaseWorld:addPlayer(actor, sourceid, haveCam)
|
function BaseWorld:addPlayer(actor, sourceid, haveCam)
|
||||||
|
@ -214,8 +219,10 @@ function BaseWorld:loadMapPlayers()
|
||||||
print("DEBUG: loading actors in player layer")
|
print("DEBUG: loading actors in player layer")
|
||||||
local i = 1
|
local i = 1
|
||||||
for k, object in pairs(objectlayer.objects) do
|
for k, object in pairs(objectlayer.objects) do
|
||||||
self:addPlayer(self.obj.Player(self, object.x, object.y), i, true)
|
if (i <= self.playerNumber) then
|
||||||
-- TODO: don't hardcode camera handling
|
-- TODO: don't hardcode camera handling
|
||||||
|
self:addPlayer(self.obj.Player(self, object.x, object.y), i, true)
|
||||||
|
end
|
||||||
i = i + 1
|
i = i + 1
|
||||||
end
|
end
|
||||||
self.map:removeLayer(objectlayer.name)
|
self.map:removeLayer(objectlayer.name)
|
||||||
|
|
Loading…
Reference in a new issue