diff options
author | Aki <nthirtyone@gmail.com> | 2016-05-17 20:07:58 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2016-05-17 20:07:58 +0200 |
commit | 1ae4804534f7d5bf308d38ae1b29de6e5bf558c4 (patch) | |
tree | c250692cfdf8cd2de3a03942999d40959d401072 /cloud.lua | |
parent | 4d2c7c76dfd99dd488edcb162fc6e6bd1f08b7ac (diff) | |
download | roflnauts-1ae4804534f7d5bf308d38ae1b29de6e5bf558c4.zip roflnauts-1ae4804534f7d5bf308d38ae1b29de6e5bf558c4.tar.gz roflnauts-1ae4804534f7d5bf308d38ae1b29de6e5bf558c4.tar.bz2 |
Spritesheet in constructor
Diffstat (limited to 'cloud.lua')
-rw-r--r-- | cloud.lua | 11 |
1 files changed, 5 insertions, 6 deletions
@@ -4,12 +4,13 @@ -- WHOLE CODE HAS FLAG OF "need a cleanup" -- Metatable of `Cloud` +-- nils initialized in constructor Cloud = { x = 0, -- position horizontal y = 0, -- position vertical t = 1, -- type (sprite number) v = 13, -- velocity - sprite = love.graphics.newImage("assets/clouds.png"), + sprite = nil, quads = { [1] = love.graphics.newQuad( 1, 1, 158,47, 478,49), [2] = love.graphics.newQuad(160, 1, 158,47, 478,49), @@ -23,11 +24,9 @@ function Cloud:new(x, y, t, v) local o = {} setmetatable(o, self) self.__index = self - -- Set filter - local min, mag = self.sprite:getFilter() - if min ~= "nearest" or - mag ~= "nearest" then - self.sprite:setFilter("nearest", "nearest") + -- Load spritesheet to metatable if not yet loaded + if self.sprite == nil then + self.sprite = love.graphics.newImage("assets/clouds.png") end -- Init o.x = x or self.x |