parent
9519130613
commit
936cdc57f3
3 changed files with 32 additions and 3 deletions
|
@ -90,6 +90,13 @@ function TestScene:new()
|
||||||
MenuType(self.menusystem, "text_menu5", x, y, w, h, 8)
|
MenuType(self.menusystem, "text_menu5", x, y, w, h, 8)
|
||||||
MenuType(self.menusystem, "text_menu6", x, y, w, h, 8)
|
MenuType(self.menusystem, "text_menu6", x, y, w, h, 8)
|
||||||
|
|
||||||
|
self.menusystem.menus["text_menu1"]:setDepth(-1)
|
||||||
|
self.menusystem.menus["text_menu2"]:setDepth(-1)
|
||||||
|
self.menusystem.menus["text_menu3"]:setDepth(-1)
|
||||||
|
self.menusystem.menus["text_menu4"]:setDepth(-1)
|
||||||
|
self.menusystem.menus["text_menu5"]:setDepth(-1)
|
||||||
|
self.menusystem.menus["text_menu6"]:setDepth(-1)
|
||||||
|
|
||||||
self:addTextWidget("text_menu1", 4)
|
self:addTextWidget("text_menu1", 4)
|
||||||
self:addTextWidget("text_menu2", 10)
|
self:addTextWidget("text_menu2", 10)
|
||||||
self:addTextWidget("text_menu3", 5)
|
self:addTextWidget("text_menu3", 5)
|
||||||
|
|
|
@ -106,10 +106,26 @@ function MenuSystem:mousepressed( x, y, button, istouch )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function MenuSystem:draw(dt) -- On dessine les entitées
|
function MenuSystem:getDrawList()
|
||||||
|
local drawList = {}
|
||||||
for k,v in pairs(self.menus) do
|
for k,v in pairs(self.menus) do
|
||||||
if (v.isVisible) then
|
local drawObject = {}
|
||||||
v:draw(dt)
|
drawObject.name = k
|
||||||
|
drawObject.depth = v.depth
|
||||||
|
table.insert(drawList, drawObject)
|
||||||
|
end
|
||||||
|
table.sort(drawList, function(a,b) return a.depth > b.depth end)
|
||||||
|
|
||||||
|
return drawList
|
||||||
|
end
|
||||||
|
|
||||||
|
function MenuSystem:draw(dt) -- On dessine les entitées
|
||||||
|
self.drawList = self:getDrawList()
|
||||||
|
|
||||||
|
for i,v in ipairs(self.drawList) do
|
||||||
|
local v2 = self.menus[v.name]
|
||||||
|
if (v2.isVisible) then
|
||||||
|
v2:draw(dt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ function Menu:new(menusystem, name, x, y, w, h)
|
||||||
self.isActive = true
|
self.isActive = true
|
||||||
self.isLocked = false
|
self.isLocked = false
|
||||||
|
|
||||||
|
self.depth = 0
|
||||||
|
|
||||||
self.sound = {}
|
self.sound = {}
|
||||||
self.sound.asset = nil
|
self.sound.asset = nil
|
||||||
self.sound.active = false
|
self.sound.active = false
|
||||||
|
@ -28,6 +30,10 @@ function Menu:new(menusystem, name, x, y, w, h)
|
||||||
self:register()
|
self:register()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Menu:setDepth(depth)
|
||||||
|
self.depth = depth or 0
|
||||||
|
end
|
||||||
|
|
||||||
function Menu:setVisibility(visibility)
|
function Menu:setVisibility(visibility)
|
||||||
if self.isLocked == false then
|
if self.isLocked == false then
|
||||||
self.isVisible = visibility
|
self.isVisible = visibility
|
||||||
|
|
Loading…
Reference in a new issue