Skip to content

Instantly share code, notes, and snippets.

@EngineerSmith
Created March 17, 2020 12:52
Show Gist options
  • Select an option

  • Save EngineerSmith/9fb2c243c8ae4317c149a98365eb7294 to your computer and use it in GitHub Desktop.

Select an option

Save EngineerSmith/9fb2c243c8ae4317c149a98365eb7294 to your computer and use it in GitHub Desktop.
local PATH = ....."."
local dirPATH = PATH:gsub("%.","/")
local helium = require("Lib.helium")
local lg = love.graphics
local function resize(element, w, h)
if element.anchor then
local v = element.view
v.x, v.y, v.w, v.h = element.anchor:getRect(w, h)
end
end
local newElement = function(file)
local factory
if helium.conf.HOTSWAP then
factory = helium.loader.loader(dirPATH..file..".lua")
else
factory = helium(require(PATH..file))
end
return function(anchor, param)
local element = factory(param)
element.anchor = anchor
element.resize = resize
element:resize(lg.getDimensions())
return element
end
end
local gui = {}
gui.anchor = require("Scripts.Ui.anchor")
gui.button = newElement("button")
gui.progressBar = newElement("progressBar")
gui.image = newElement("image")
return gui
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment