dialog.lua
1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
--[[
@Author : z_h
@Date : 2016-06-20 10:00:19
@Content :
--]]
local director = cc.Director:getInstance()
local size = director:getWinSize()
local dispatcher = director:getEventDispatcher()
module("dialog", package.seeall)
ZORDER_APP = 100
ZORDER_POP = 1000
uinode = function(path, ...)
local creator = function() return cc.CSLoader:createNode(path) end
local cls_name = string.format("uinode(%s)", path)
local cls = class(cls_name, creator, ...)
return cls
end
uilayer = function(path, ...)
local creator = function()
local node = cc.CSLoader:createNode(path):setContentSize(size)
ccui.Helper:doLayout(node)
return node
end
local cls_name = string.format("uilayer(%s)", path)
local cls = class(cls_name, creator, ...)
return cls
end
local _bg = nil
local _stack = {}
local _scene = nil
local function attachToScene(scene)
_scene = scene
_stack = {}
if tolua.isnull(_bg) then
_bg = cc.LayerColor:create(cc.c4b(0, 0, 0, 200))
local listener = cc.EventListenerTouchOneByOne:create()
listener:registerScriptHandler(function() return true end,
cc.Handler.EVENT_TOUCH_BEGAN)
listener:setSwallowTouches(true)
dispatcher:addEventListenerWithSceneGraphPriority(listener, _bg)
end
_bg:retain()
if _bg:getParent() then
_bg:removeFromParent(true)
end
end