summaryrefslogtreecommitdiffhomepage
path: root/not/Layer.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-13 12:50:46 +0200
committerAki <nthirtyone@gmail.com>2017-09-13 12:50:46 +0200
commitf34ec5f8f29ce07d69104e537e87ed357abaf786 (patch)
treee660423a379e25be1184bda85fdf39218126f4fb /not/Layer.lua
parente8bd3dfd8031930fa3f0169300620e5a0400995d (diff)
downloadroflnauts-f34ec5f8f29ce07d69104e537e87ed357abaf786.zip
roflnauts-f34ec5f8f29ce07d69104e537e87ed357abaf786.tar.gz
roflnauts-f34ec5f8f29ce07d69104e537e87ed357abaf786.tar.bz2
Camera and Layers now properly handle different resolution ratios
Diffstat (limited to 'not/Layer.lua')
-rw-r--r--not/Layer.lua15
1 files changed, 5 insertions, 10 deletions
diff --git a/not/Layer.lua b/not/Layer.lua
index ebfb28e..14dac32 100644
--- a/not/Layer.lua
+++ b/not/Layer.lua
@@ -1,11 +1,11 @@
--- A little bit more than just a Canvas.
--- TODO: Scaled and RealScaled support should be extended.
Layer = require "not.Object":extends()
function Layer:new (width, height)
self.canvas = love.graphics.newCanvas(width, height)
- self.scale = false
- self.ratio = false
+ self.transformScale = getScale()
+ self.transformRatio = 1
+ self.drawScale = 1
end
function Layer:delete ()
@@ -28,8 +28,7 @@ end
function Layer:renderToWith (camera, func, ...)
camera:push()
- camera:scale(self.scale)
- camera:translate(self.ratio)
+ camera:transform(self.transformScale, self.transformRatio, self.canvas:getDimensions())
self:renderTo(func, ...)
camera:pop()
end
@@ -39,12 +38,8 @@ function Layer:clear ()
end
function Layer:draw ()
- local scale = 1
- if self.scale then
- scale = getScale() / self.scale
- end
love.graphics.setColor(255, 255, 255, 255)
- love.graphics.draw(self.canvas, nil, nil, nil, scale, scale)
+ love.graphics.draw(self.canvas, nil, nil, nil, self.drawScale, self.drawScale)
end
return Layer