diff options
author | Aki <nthirtyone@gmail.com> | 2017-09-12 03:34:23 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-09-12 03:34:23 +0200 |
commit | 9e29f6127fc27e58a5680a8aa6bea7336add4755 (patch) | |
tree | 3d71934a4a8daf61a97de5c901d6401a7084db21 /not/Layer.lua | |
parent | 2b2c4b06ec483e02bda201548ab89a6d0d116c19 (diff) | |
download | roflnauts-9e29f6127fc27e58a5680a8aa6bea7336add4755.zip roflnauts-9e29f6127fc27e58a5680a8aa6bea7336add4755.tar.gz roflnauts-9e29f6127fc27e58a5680a8aa6bea7336add4755.tar.bz2 |
Added renderToWith to shorten using Camera with Layers
Diffstat (limited to 'not/Layer.lua')
-rw-r--r-- | not/Layer.lua | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/not/Layer.lua b/not/Layer.lua index 126b402..6be61c4 100644 --- a/not/Layer.lua +++ b/not/Layer.lua @@ -3,6 +3,8 @@ Layer = require "not.Object":extends() function Layer:new (width, height) self.canvas = love.graphics.newCanvas(width, height) + self.scale = false + self.ratio = false end function Layer:delete () @@ -23,6 +25,14 @@ function Layer:renderTo (func, ...) love.graphics.setCanvas(c) end +function Layer:renderToWith (camera, func, ...) + camera:push() + camera:scale(self.scale) + camera:translate(self.ratio) + self:renderTo(func, ...) + camera:pop() +end + function Layer:clear () self:renderTo(love.graphics.clear) end |