diff options
author | Aki <nthirtyone@gmail.com> | 2017-09-08 15:59:39 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-09-08 15:59:39 +0200 |
commit | 5ef20afaf6a9aca1999faf8904594d94fcfaaa66 (patch) | |
tree | a41526816a95d4f1ae35c714cd9a462fb6ee4d68 /not/Layer.lua | |
parent | cff3a516083df2e43f6936812baba56a622d804a (diff) | |
download | roflnauts-5ef20afaf6a9aca1999faf8904594d94fcfaaa66.zip roflnauts-5ef20afaf6a9aca1999faf8904594d94fcfaaa66.tar.gz roflnauts-5ef20afaf6a9aca1999faf8904594d94fcfaaa66.tar.bz2 |
Created Layer class
Diffstat (limited to 'not/Layer.lua')
-rw-r--r-- | not/Layer.lua | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/not/Layer.lua b/not/Layer.lua new file mode 100644 index 0000000..db16175 --- /dev/null +++ b/not/Layer.lua @@ -0,0 +1,27 @@ +--- A little bit more than just a Canvas. +Layer = require "not.Object":extends() + +function Layer:new (width, height) + self.canvas = love.graphics.newCanvas(width, height) +end + +--- Sets this layer as current canvas for drawing with love.graphics functions. +-- @return old canvas used by love +function Layer:setAsCanvas () + local c = love.graphics.getCanvas() + love.graphics.setCanvas(self.canvas) + return c +end + +function Layer:clear () + local c = self:setAsCanvas() + love.graphics.clear() + love.graphics.setCanvas(c) +end + +function Layer:draw () + love.graphics.setColor(255, 255, 255, 255) + love.graphics.draw(self.canvas) +end + +return Layer |