summaryrefslogtreecommitdiffhomepage
path: root/not/Sprite.lua
diff options
context:
space:
mode:
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)