improvement(camera): use the shape system to control the camera.
This commit is contained in:
parent
c06f1c49aa
commit
940cb1b41f
1 changed files with 10 additions and 9 deletions
|
@ -357,18 +357,19 @@ function CameraSystem:followAllActors(id)
|
||||||
if (#self.targets > 0) then
|
if (#self.targets > 0) then
|
||||||
local minX, minY, maxX, maxY
|
local minX, minY, maxX, maxY
|
||||||
for i, target in ipairs(self.targets) do
|
for i, target in ipairs(self.targets) do
|
||||||
local xx, yy = target:getViewCenter()
|
local x, y, w, h = target:getShape()
|
||||||
|
local x2, y2 = x + w, y + h
|
||||||
-- If start by initializing the value at the first found value
|
-- If start by initializing the value at the first found value
|
||||||
if (minX == nil) then minX = xx - (target.w/2) end
|
if (minX == nil) then minX = x end
|
||||||
if (maxX == nil) then maxX = xx + (target.w/2) end
|
if (maxX == nil) then maxX = x2 end
|
||||||
if (minY == nil) then minY = yy - (target.h/2) end
|
if (minY == nil) then minY = y end
|
||||||
if (maxY == nil) then maxY = yy + (target.h/2) end
|
if (maxY == nil) then maxY = y2 end
|
||||||
|
|
||||||
|
|
||||||
minX = math.min(minX, xx - (target.w/2))
|
minX = math.min(minX, x)
|
||||||
maxX = math.max(maxX, xx + (target.w/2))
|
maxX = math.max(maxX, x2)
|
||||||
minY = math.min(minY, yy - (target.h/2))
|
minY = math.min(minY, y)
|
||||||
maxY = math.max(maxY, yy + (target.h/2))
|
maxY = math.max(maxY, y2)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add padding
|
-- Add padding
|
||||||
|
|
Loading…
Reference in a new issue