Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local GCGUI = {}
- function GCGUI.newGroup()
- local myGroup = {}
- myGroup.elements = {}
- function myGroup:addElement(pElement)
- table.insert(self.elements,pElement)
- end
- function myGroup:setVisible(pVisible)
- for n,v in pairs(myGroup.elements) do
- v:setVisible(pVisible)
- end
- end
- function myGroup:draw()
- love.graphics.push()
- for n,v in pairs(myGroup.elements) do
- v:draw()
- end
- love.graphics.pop()
- end
- return myGroup
- end
- local function newElement(pX,pY)
- local myElement = {}
- myElement.x = pX
- myElement.y = pY
- function myElement:draw()
- end
- function myElement:setVisible(pVisible)
- self.visible = pVisible
- end
- return myElement
- end
- function GCGUI.newPanel(pX,pY,pW,pH)
- local myPanel = newElement(pX,pY)
- myPanel.W = pW
- myPanel.H = pH
- myPanel.image = nil
- function myPanel:setImage(pImage)
- self.image = pImage
- self.W = pImage:getWidth()
- self.H = pImage:getHeight()
- end
- function myPanel:drawPanel()
- love.graphics.setColor(1,1,1)
- if self.image == nil then
- love.graphics.rectangle("line",self.x,self.y,self.W,self.H)
- else
- love.graphics.draw(self.image,self.x,self.y)
- end
- end
- function myPanel:draw()
- if self.visible == false then return end
- self:drawPanel()
- end
- return myPanel
- end
- return GCGUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement