GameStartView.lua
2 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
local GameStartView = dialog.uinode("ui/cake/CakeStartLayer.csb",import("..view.BaseViewNew"))
function GameStartView:ctor()
GameStartView.super.ctor(self);
end
function GameStartView:show(onStartFn)
local scene = cc.Director:getInstance():getRunningScene()
local inst = GameStartView:create();
scene:addChild(inst, dialog.ZORDER_POP);
inst.onStartFn = onStartFn;
inst:init();
return inst;
end
function GameStartView:init()
self:setContentSize(cc.size(display.width,display.height));
ccui.Helper:doLayout(self);
local btn_start = self:getChildByName("btn_start");
btn_start.fn = handler(self,self.onStart);
btn_start:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_start.fn)end);
local btn_introduce = self:getChildByName("btn_introduce");
btn_introduce.fn = handler(self,self.onIntroduce);
btn_introduce:addTouchEventListener(function(ref,type) self:onButtonClick(ref,type, btn_introduce.fn)end);
self.bg_mask = self:getChildByName("bg_mask");
self.bg_mask:hide();
self.game_introduce = self:getChildByName("game_introduce");
self.game_introduce:hide();
self.nodes[1] = {btn_start,btn_introduce};
self:updateSelectedState(btn_start);
end
function GameStartView:onStart()
if self.onStartFn then
self.onStartFn();
end
SoundManager.playEffect("res/ui/cake/star.ogg");
self:close();
end
function GameStartView:onIntroduce()
if not self.game_introduce:isVisible() then
self.game_introduce:show();
self.bg_mask:show();
else
self.game_introduce:hide();
self.bg_mask:hide();
end
end
--返回键处理函数
function GameStartView:onKeypadBack()
local function okFun()
cc.Director:getInstance():endToLua();
end
local receiver = require("app.views.view.AlertView"):show({msg="确定要退出游戏?"},okFun,cancelFun,2);
cc.Director:getInstance():getRunningScene().keypadManager:addKeypadReceiver(receiver);
end
return GameStartView