modules/world: attach and detach view just once

This commit is contained in:
Kazhnuz 2019-05-02 17:21:48 +02:00
parent aaf0b1882b
commit eddf66595c

View file

@ -288,19 +288,19 @@ function BaseWorld:draw(dt)
self:drawActors() self:drawActors()
else else
for i=1, camNumber do for i=1, camNumber do
self.cameras:attachView(i)
self:drawMap(i) self:drawMap(i)
self:drawActors(i) self:drawActors(i)
self.cameras:detachView(i)
end end
end end
end end
function BaseWorld:drawActors(id) function BaseWorld:drawActors(id)
self.cameras:attachView(id)
local actors = self:getActors() local actors = self:getActors()
for i,v in ipairs(actors) do for i,v in ipairs(actors) do
v:draw() v:draw()
end end
self.cameras:detachView(id)
end end
function BaseWorld:drawMap(id) function BaseWorld:drawMap(id)
@ -317,9 +317,7 @@ function BaseWorld:drawMap(id)
end end
if self.haveMap then if self.haveMap then
self.cameras:attachView(id)
self.map:draw(-tx, -ty, scale, scale) self.map:draw(-tx, -ty, scale, scale)
self.cameras:detachView(id)
end end
end end