Added text buttons and button groups.
This commit is contained in:
@@ -3,21 +3,19 @@
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
local make_class = require 'src.utils.classes'
|
||||
local Asset = require 'src.utils.asset'
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Class definitions
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
local Drawable = make_class(Asset)
|
||||
local Drawable = make_class()
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Class methods
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
function Drawable:_init(file_name)
|
||||
Asset._init(self, file_name)
|
||||
function Drawable:_init()
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
|
||||
local love = require 'love'
|
||||
local make_class = require 'src.utils.classes'
|
||||
local Asset = require 'src.utils.asset'
|
||||
local Drawable = require 'src.graphics.drawable'
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Class definitions
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
local Sprite = make_class(Drawable)
|
||||
local Sprite = make_class(Drawable, Asset)
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
@@ -18,14 +19,26 @@ local Sprite = make_class(Drawable)
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
function Sprite:_init(file_name, x, y)
|
||||
Drawable._init(self, file_name)
|
||||
Asset._init(self, file_name)
|
||||
self.x = (x ~= nil and x) or 0
|
||||
self.y = (y ~= nil and y) or 0
|
||||
end
|
||||
|
||||
|
||||
function Sprite:load()
|
||||
self.sprite = love.graphics.newImage(self.file_name)
|
||||
if not self:is_loaded() then
|
||||
self.sprite = love.graphics.newImage(self.file_name)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function Sprite:unload()
|
||||
self.sprite = nil
|
||||
end
|
||||
|
||||
|
||||
function Sprite:is_loaded()
|
||||
return self.sprite ~= nil
|
||||
end
|
||||
|
||||
|
||||
@@ -36,11 +49,6 @@ function Sprite:draw()
|
||||
end
|
||||
|
||||
|
||||
function Sprite:unload()
|
||||
self.sprite = nil
|
||||
end
|
||||
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
-- Module return
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user