chore(baseworld): make drawing reordering part of getVisibleActors(id)
This commit is contained in:
parent
ce48e451c1
commit
a60058522b
1 changed files with 24 additions and 22 deletions
|
@ -144,15 +144,30 @@ end
|
|||
|
||||
|
||||
function BaseWorld:getVisibleActors(id)
|
||||
local camx, camy, camw, camh = self.cameras:getViewCoordinate(id)
|
||||
local paddingw = camw * PADDING_VALUE
|
||||
local paddingh = camh * PADDING_VALUE
|
||||
local x = camx - paddingw
|
||||
local y = camy - paddingh
|
||||
local w = camw + paddingw * 2
|
||||
local h = camh + paddingh * 2
|
||||
local actors = {}
|
||||
if (id ~= nil) then
|
||||
local camx, camy, camw, camh = self.cameras:getViewCoordinate(id)
|
||||
local paddingw = camw * PADDING_VALUE
|
||||
local paddingh = camh * PADDING_VALUE
|
||||
local x = camx - paddingw
|
||||
local y = camy - paddingh
|
||||
local w = camw + paddingw * 2
|
||||
local h = camh + paddingh * 2
|
||||
|
||||
return self:getActorsInRect(x, y, w, h)
|
||||
actors = self:getActorsInRect(x, y, w, h)
|
||||
else
|
||||
actors = self:getActors()
|
||||
end
|
||||
|
||||
table.sort(actors, function(a,b)
|
||||
if (a.depth == b.depth) then
|
||||
return a.creationID < b.creationID
|
||||
else
|
||||
return a.depth > b.depth
|
||||
end
|
||||
end)
|
||||
|
||||
return actors
|
||||
end
|
||||
|
||||
-- BODIES MANAGEMENT FUNCTIONS
|
||||
|
@ -426,20 +441,7 @@ function BaseWorld:draw(dt)
|
|||
end
|
||||
|
||||
function BaseWorld:drawActors(id)
|
||||
local actors
|
||||
if (id == nil) then
|
||||
actors = self:getActors()
|
||||
else
|
||||
actors = self:getVisibleActors(id)
|
||||
end
|
||||
|
||||
table.sort(actors, function(a,b)
|
||||
if (a.depth == b.depth) then
|
||||
return a.creationID < b.creationID
|
||||
else
|
||||
return a.depth > b.depth
|
||||
end
|
||||
end)
|
||||
local actors = self:getVisibleActors(id)
|
||||
|
||||
for i,v in ipairs(actors) do
|
||||
v:draw()
|
||||
|
|
Loading…
Reference in a new issue