fix: fix scissoring in 2x screens

This commit is contained in:
Kazhnuz 2019-08-15 15:09:48 +02:00
parent 45c58bcbcd
commit 01dc81ed0f
3 changed files with 16 additions and 4 deletions

View file

@ -81,6 +81,18 @@ function ScreenManager:getDimensions()
return self.width, self.height return self.width, self.height
end end
-- SCISSOR FUNCTIONS
-- Simple scissor functions
function ScreenManager:setScissor(x, y, width, height)
local x, y = self:getScreenCoordinate(x, y)
love.graphics.setScissor(x, y, width*self.data.resolution, height*self.data.resolution)
end
function ScreenManager:resetScissor()
love.graphics.setScissor( )
end
-- DRAW FUNCTIONS -- DRAW FUNCTIONS
-- Apply draw functions to the scene -- Apply draw functions to the scene

View file

@ -43,12 +43,12 @@ end
function gui.drawBar(x, y, width, height) function gui.drawBar(x, y, width, height)
if (width > 0) then if (width > 0) then
local height = height or 7 local height = height or 7
love.graphics.setScissor(x, y, width, height) core.screen:setScissor(x, y, width, height)
love.graphics.draw(barborder, x, y) love.graphics.draw(barborder, x, y)
local barwidth = math.max(width-14, 0) local barwidth = math.max(width-14, 0)
love.graphics.rectangle("fill", x+7, y, barwidth, height) love.graphics.rectangle("fill", x+7, y, barwidth, height)
love.graphics.draw(barborder, x+width-7, y, 0, -1, -1, 7, 7) love.graphics.draw(barborder, x+width-7, y, 0, -1, -1, 7, 7)
love.graphics.setScissor( ) core.screen:resetScissor( )
end end
end end

View file

@ -232,9 +232,9 @@ function Hero:drawHUD()
local y = 36 local y = 36
self.assets.images["e_speedster"]:draw(x, y) self.assets.images["e_speedster"]:draw(x, y)
love.graphics.setScissor(x, y-16, 32, 40) core.screen:setScissor(x, y-16, 32, 40)
self.assets.sprites[self.charid]:drawAnimation(x+14, y+14) self.assets.sprites[self.charid]:drawAnimation(x+14, y+14)
love.graphics.setScissor( ) core.screen:resetScissor( )
self.assets.images["m_speedster"]:draw(x, y) self.assets.images["m_speedster"]:draw(x, y)
self.assets.images["statusbar"]:draw(x+12, y-6) self.assets.images["statusbar"]:draw(x+12, y-6)