parent
fafaa3fe49
commit
208c523248
2 changed files with 23 additions and 14 deletions
|
@ -431,11 +431,13 @@ function BaseWorld:draw(dt)
|
||||||
self:drawActors()
|
self:drawActors()
|
||||||
else
|
else
|
||||||
for i=1, camNumber do
|
for i=1, camNumber do
|
||||||
|
self.cameras:setScissor(i)
|
||||||
self:drawMap(i)
|
self:drawMap(i)
|
||||||
self.cameras:attachView(i)
|
self.cameras:attachView(i)
|
||||||
self:drawActors(i)
|
self:drawActors(i)
|
||||||
self.cameras:detachView(i)
|
self.cameras:detachView(i)
|
||||||
self.cameras:drawHUD(i)
|
self.cameras:drawHUD(i)
|
||||||
|
self.cameras:resetScissor( )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -194,21 +194,32 @@ function CameraSystem:getViewCam(id)
|
||||||
return view.cam
|
return view.cam
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function CameraSystem:setScissor(id)
|
||||||
|
local viewx, viewy, vieww, viewh = self:getOnScreenViewCoordinate(id)
|
||||||
|
|
||||||
|
if (self:getViewNumber() > 2) or (self:getViewNumber() == 2 and SPLITSCREEN_ISVERTICAL) then
|
||||||
|
-- FIXME: it's an ugly workaround that need to be fixed. For an unkown
|
||||||
|
-- reason, the scissoring is wrong in and only in this function and only
|
||||||
|
-- when we have vertical split. Thus, we need to substract viewy to viewy
|
||||||
|
viewy = viewh - viewy
|
||||||
|
end
|
||||||
|
|
||||||
|
if (self.mode == "split") then
|
||||||
|
love.graphics.setScissor(viewx, viewy, vieww, viewh)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function CameraSystem:resetScissor( )
|
||||||
|
if (self.mode == "split") then
|
||||||
|
love.graphics.setScissor( )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function CameraSystem:attachView(id)
|
function CameraSystem:attachView(id)
|
||||||
if (id ~= nil) then
|
if (id ~= nil) then
|
||||||
local cam = self:getViewCam(id)
|
local cam = self:getViewCam(id)
|
||||||
|
|
||||||
local viewx, viewy, vieww, viewh = self:getOnScreenViewCoordinate(id)
|
|
||||||
cam:attach()
|
cam:attach()
|
||||||
|
|
||||||
if (self:getViewNumber() > 2) or (self:getViewNumber() == 2 and SPLITSCREEN_ISVERTICAL) then
|
|
||||||
-- FIXME: it's an ugly workaround that need to be fixed. For an unkown
|
|
||||||
-- reason, the scissoring is wrong in and only in this function and only
|
|
||||||
-- when we have vertical split. Thus, we need to substract viewy to viewy
|
|
||||||
viewy = viewh - viewy
|
|
||||||
end
|
|
||||||
|
|
||||||
love.graphics.setScissor(viewx, viewy, vieww, viewh)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -216,7 +227,6 @@ function CameraSystem:detachView(id)
|
||||||
if (id ~= nil) then
|
if (id ~= nil) then
|
||||||
local cam = self:getViewCam(id)
|
local cam = self:getViewCam(id)
|
||||||
|
|
||||||
love.graphics.setScissor( )
|
|
||||||
cam:detach()
|
cam:detach()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -417,13 +427,10 @@ function CameraSystem:drawHUD(id)
|
||||||
local view = self:getView(id)
|
local view = self:getView(id)
|
||||||
local string2 = id .. " (" .. viewx .. ":" .. (viewh-viewy) .. ") "
|
local string2 = id .. " (" .. viewx .. ":" .. (viewh-viewy) .. ") "
|
||||||
|
|
||||||
|
|
||||||
love.graphics.setScissor(viewx, viewy, vieww, viewh)
|
|
||||||
love.graphics.translate(viewx, viewy)
|
love.graphics.translate(viewx, viewy)
|
||||||
view.target:drawHUD(id, vieww, viewh)
|
view.target:drawHUD(id, vieww, viewh)
|
||||||
|
|
||||||
love.graphics.translate(-viewx, -(viewy))
|
love.graphics.translate(-viewx, -(viewy))
|
||||||
love.graphics.setScissor( )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return CameraSystem
|
return CameraSystem
|
||||||
|
|
Loading…
Reference in a new issue