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 | |
parent | 4d2c7c76dfd99dd488edcb162fc6e6bd1f08b7ac (diff) | |
download | roflnauts-1ae4804534f7d5bf308d38ae1b29de6e5bf558c4.zip roflnauts-1ae4804534f7d5bf308d38ae1b29de6e5bf558c4.tar.gz roflnauts-1ae4804534f7d5bf308d38ae1b29de6e5bf558c4.tar.bz2 |
Spritesheet in constructor
-rw-r--r-- | cloud.lua | 11 | ||||
-rw-r--r-- | effect.lua | 12 |
2 files changed, 10 insertions, 13 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 @@ -6,11 +6,11 @@ Effect = { x = 0, y = 0, - delay = 0.08, + delay = 0.06, initial = nil, frame = 1, animation = nil, - sprite = love.graphics.newImage("assets/effects.png"), + sprite = nil, quads = require "effects" } @@ -20,11 +20,9 @@ function Effect:new(name, x, y) 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/effects.png") end -- Init o.initial = o.delay |