summaryrefslogtreecommitdiffhomepage
path: root/not/Sprite.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-03-19 01:35:43 +0100
committerAki <nthirtyone@gmail.com>2017-03-19 01:35:43 +0100
commitb262cb3eec1a797832d168f9e6d144468fb48c1d (patch)
tree3bdc06329029d44f14515830afacee7410b69956 /not/Sprite.lua
parent340a3a4b92de5495b47e8e1e102178edfd97514f (diff)
downloadroflnauts-b262cb3eec1a797832d168f9e6d144468fb48c1d.zip
roflnauts-b262cb3eec1a797832d168f9e6d144468fb48c1d.tar.gz
roflnauts-b262cb3eec1a797832d168f9e6d144468fb48c1d.tar.bz2
Initializers in PhysicalBody, Hero and Sprite
Diffstat (limited to 'not/Sprite.lua')
-rw-r--r--not/Sprite.lua11
1 files changed, 8 insertions, 3 deletions
diff --git a/not/Sprite.lua b/not/Sprite.lua
index 905816b..6342f60 100644
--- a/not/Sprite.lua
+++ b/not/Sprite.lua
@@ -12,9 +12,7 @@ Sprite.__index = Sprite
-- Constructor of `Sprite`.
function Sprite:new (imagePath)
local o = setmetatable({}, self)
- if type(imagePath) == "string" then
- o:setImage(self.newImage(imagePath))
- end
+ o:init(imagePath)
return o
end
@@ -23,6 +21,13 @@ function Sprite:delete ()
self.image = nil
end
+-- Initializes new Sprite instance.
+function Sprite:init (imagePath)
+ if type(imagePath) == "string" then
+ self:setImage(Sprite.newImage(imagePath))
+ end
+end
+
-- Creates new Image object from path. Key-colours two shades of green. Static.
function Sprite.newImage (path)
local imagedata = love.image.newImageData(path)