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.
93 lines
2.7 KiB
93 lines
2.7 KiB
3 months ago
|
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) {}
|
||
|
}
|