You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
99 lines
3.0 KiB
99 lines
3.0 KiB
// Learn TypeScript:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
|
|
// Learn Attribute:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
|
|
// Learn life-cycle callbacks:
|
|
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
|
|
|
|
import { ryw_Event } from "../../FrameWork/Event/EventEnum";
|
|
import EventMgr from "../../FrameWork/Event/EventMgr";
|
|
import GameReport from "../../FrameWork/Report/ZyZyReport";
|
|
|
|
import Common from "../../FrameWork/Util/Common";
|
|
import Common5 from "../../Platform/th/Common5";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class ChooseBtnLayer extends cc.Component {
|
|
|
|
@property(cc.Node)
|
|
btnNode: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
btnNodeContent: cc.Node = null;
|
|
|
|
|
|
|
|
// onLoad () {}
|
|
|
|
protected onEnable(): void {
|
|
this.setCloseBtnShow(false)
|
|
console.log('hide++++++++====')
|
|
}
|
|
|
|
start() {
|
|
|
|
}
|
|
|
|
|
|
setCloseBtnShow(show) {
|
|
console.log('show++++++++====')
|
|
if (this.node.getChildByName('closeBtn')) {
|
|
this.node.getChildByName('closeBtn').active = show
|
|
}
|
|
|
|
}
|
|
|
|
closeBtnClickEvent() {
|
|
Common5.playEffect("点击音效");
|
|
this.node.active = false
|
|
EventMgr.emitEvent_custom(ryw_Event.chooseResult, { touchIndex: -1 })
|
|
}
|
|
|
|
|
|
setChooseBtnView() {
|
|
this.btnNodeContent.removeAllChildren()
|
|
let btnArray = Common.GameSubChooseArray.btnArray
|
|
let chooseTitle = Common.GameSubChooseArray.chooseTitle
|
|
for (let i = 0; i < btnArray.length; i++) {
|
|
let btnNode = cc.instantiate(this.btnNode)
|
|
btnNode.name = "选项:" + btnArray[i];
|
|
btnNode.active = true
|
|
this.btnNodeContent.addChild(btnNode)
|
|
btnNode.setPosition(cc.v2(0, 0))
|
|
|
|
let lab = btnNode.getChildByName('lab').getComponent(cc.Label)
|
|
lab.string = btnArray[i]
|
|
btnNode['touchIndex'] = i
|
|
}
|
|
|
|
if (this.node.getChildByName('title')) {
|
|
this.node.getChildByName('title').getComponent(cc.Label).string = chooseTitle
|
|
}
|
|
}
|
|
|
|
|
|
chooseBtnClickEvent(event) {
|
|
Common5.playEffect("点击音效");
|
|
let target = event.target
|
|
let touchIndex = target['touchIndex']
|
|
|
|
GameReport.BtnsReport(target.name, Common5.selectGameInfo.titleUrl);
|
|
|
|
console.log("[GameReport]++++++++++++++++++++++>" + target.name);
|
|
if (Common.GameSubChooseArray.btnArrayResult) {
|
|
let btnArrayResult = Common.GameSubChooseArray.btnArrayResult
|
|
let result = btnArrayResult[touchIndex]
|
|
this.node.active = false
|
|
EventMgr.emitEvent_custom(ryw_Event.chooseResult, { result: result, touchIndex: touchIndex })
|
|
} else {
|
|
this.node.active = false
|
|
EventMgr.emitEvent_custom(ryw_Event.chooseResult, { touchIndex: touchIndex })
|
|
}
|
|
console.log('ChooseBtnLayer chooseBtnClickEvent++++++++====')
|
|
this.node.active = false
|
|
|
|
}
|
|
// update (dt) {}
|
|
}
|
|
|