diff options
author | Aki <nthirtyone@gmail.com> | 2016-08-23 18:15:55 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2016-08-23 18:15:55 +0200 |
commit | d41d75e723cfd7d49456da1e27d98f0c806afaca (patch) | |
tree | 14ed9af01a0c0efad15f02309d6fb179bc0a2052 /element.lua | |
parent | 63d90193f50f5fec561f725d8bda1fcb7ad6c3b8 (diff) | |
download | roflnauts-d41d75e723cfd7d49456da1e27d98f0c806afaca.zip roflnauts-d41d75e723cfd7d49456da1e27d98f0c806afaca.tar.gz roflnauts-d41d75e723cfd7d49456da1e27d98f0c806afaca.tar.bz2 |
2
Diffstat (limited to 'element.lua')
-rw-r--r-- | element.lua | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/element.lua b/element.lua new file mode 100644 index 0000000..bc8bc6d --- /dev/null +++ b/element.lua @@ -0,0 +1,46 @@ +-- `Element` +-- Empty element for `Menu` creation. Can be anything. +Element = { + x = 0, + y = 0, + parent +} +function Element:new(parent) + local o = {} + setmetatable(o, self) + self.__index = self + o.parent = parent + return o +end +function Element:delete() end -- deletes Element +function Element:getPosition() return self.x, self.y end -- gives x,y of Element +function Element:setPosition(x,y) + self.x, self.y = x, y + return self +end +function Element:set(name, func) + if type(name) == "string" and func ~= nil then + self[name] = func + end + return self +end + +-- Menu callbacks +function Header:focus(next) -- Called when Element gains focus + if next and self.parent then + self.parent:next() + else + self.parent:previous() + end +end +function Element:blur() end -- Called when Element loses focus + +-- LÖVE2D callbacks +function Element:draw(scale) end +function Element:update(dt) end + +-- Controller callbacks +function Element:controlpressed(set, action, key) end +function Element:controlreleased(set, action, key) end + +return Element
\ No newline at end of file |