132 lines
3.5 KiB
JavaScript
132 lines
3.5 KiB
JavaScript
cc.Class({
|
|
extends: cc.Component,
|
|
|
|
properties: {
|
|
scrollContent: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
scrollView: {
|
|
default: null,
|
|
type: cc.ScrollView
|
|
},
|
|
mainScrollPrefab: {
|
|
default: null,
|
|
type: cc.Prefab
|
|
},
|
|
topMenuBtn: {
|
|
default: null,
|
|
type: cc.Button
|
|
},
|
|
mainScrollContent: {
|
|
default: null,
|
|
type: cc.Node
|
|
},
|
|
topMenuPrefab: {
|
|
default: null,
|
|
type: cc.Prefab
|
|
},
|
|
infoMenuPrefab: {
|
|
default: null,
|
|
type: cc.Prefab
|
|
},
|
|
inviteMenuPrefab: {
|
|
default: null,
|
|
type: cc.Prefab
|
|
},
|
|
rulePrefab: {
|
|
default: null,
|
|
type: cc.Prefab
|
|
},
|
|
resultPrefab: {
|
|
default: null,
|
|
type: cc.Prefab
|
|
},
|
|
menuContentPrefab: {
|
|
default: null,
|
|
type: cc.Prefab
|
|
},
|
|
topMenu: {
|
|
default: null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
onLoad () {
|
|
let self = this;
|
|
this.mainScrollContent = cc.instantiate(this.mainScrollPrefab);
|
|
this.scrollContent.addChild(this.mainScrollContent);
|
|
this.mainScrollContent.getComponent('scrollContent').joinBtn.on('click', function () {
|
|
self.showInfoMenu();
|
|
});
|
|
this.mainScrollContent.getComponent('scrollContent').inviteBtn.on('click', function () {
|
|
self.showInviteMenu();
|
|
});
|
|
this.mainScrollContent.getComponent('scrollContent').ruleBtn.on('click', function () {
|
|
self.showRuleMenu();
|
|
});
|
|
let topHeader = cc.instantiate(this.topMenuPrefab);
|
|
this.node.addChild(topHeader, 10);
|
|
topHeader.getComponent('topMenu').menuBtn.on('click', function () {
|
|
self.showTopMenu();
|
|
});
|
|
this.scrollView.node.on('scroll-ended', function (e) {
|
|
});
|
|
},
|
|
|
|
start () {
|
|
},
|
|
onDestroy: function () {
|
|
onfire.un(this.topMenuListener);
|
|
},
|
|
// update (dt) {},
|
|
showTopMenu() {
|
|
if (!this.topMenu) {
|
|
this.topMenu = cc.instantiate(this.menuContentPrefab);
|
|
this.node.addChild(this.topMenu, 9);
|
|
this.topMenuListener = onfire.on("topMenuClick", this.onTopMenuClick.bind(this));
|
|
} else {
|
|
this.topMenu.active = !this.topMenu.active ;
|
|
}
|
|
},
|
|
|
|
onTopMenuClick: function (idx) {
|
|
console.log(idx);
|
|
let y = 0;
|
|
switch (idx) {
|
|
case 1:
|
|
y = 1560;
|
|
break;
|
|
case 2:
|
|
y = 2920;
|
|
break;
|
|
case 3:
|
|
y = 3666;
|
|
break;
|
|
case 4:
|
|
y = 4686;
|
|
break;
|
|
default:
|
|
y = 0;
|
|
break;
|
|
}
|
|
this.scrollView.scrollToOffset(cc.v2(0, y), 0.1);
|
|
this.topMenu.active = false;
|
|
},
|
|
showInfoMenu() {
|
|
let infoMenu = cc.instantiate(this.infoMenuPrefab);
|
|
infoMenu.getComponent('infoMenu').top = this;
|
|
this.node.addChild(infoMenu, 11);
|
|
},
|
|
showInviteMenu() {
|
|
let inviteMenu = cc.instantiate(this.inviteMenuPrefab);
|
|
this.node.addChild(inviteMenu, 11);
|
|
},
|
|
showRuleMenu() {
|
|
let ruleMenu = cc.instantiate(this.rulePrefab);
|
|
this.node.addChild(ruleMenu, 11);
|
|
}
|
|
});
|