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.
108 lines
2.6 KiB
108 lines
2.6 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 Common from "../../../FrameWork/Util/Common";
|
|
import Common5 from "../../../Platform/th/Common5";
|
|
|
|
//规则layer
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class GuiZeLayer extends cc.Component {
|
|
|
|
@property(cc.Node)
|
|
leftNode: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
rightNode: cc.Node = null;
|
|
|
|
@property(cc.Node)
|
|
guizeIcon: cc.Node = null;
|
|
|
|
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {}
|
|
guizeArray = []
|
|
curIndex = 0
|
|
start () {
|
|
|
|
}
|
|
|
|
setGuizeArray(curIndex){
|
|
|
|
this.curIndex = curIndex
|
|
//this.guizeArray = []
|
|
for(let i = 0; i<=curIndex; i++){
|
|
if( this.guizeArray.indexOf(i) < 0){
|
|
this.guizeArray.push(i)
|
|
}
|
|
|
|
}
|
|
this.refreshView()
|
|
}
|
|
|
|
refreshView(){
|
|
// icon 规则显示
|
|
let aaa = this.guizeArray[this.curIndex]
|
|
//console.log('当前规则index++===', aaa)
|
|
let data = Common.GameguizeArray[aaa]
|
|
|
|
|
|
if(data && data.url){
|
|
let bundle = Common5.selectGameInfo.bundle
|
|
Common5.getSpriteFrameFromBundle(bundle, data.url, this.guizeIcon.getComponent(cc.Sprite));
|
|
}
|
|
this.showLeftORightBtn()
|
|
}
|
|
|
|
closeClickEvent(){
|
|
Common5.playEffect("点击音效");
|
|
this.node.active = false
|
|
}
|
|
|
|
leftClickEvent(){
|
|
Common5.playEffect("点击音效");
|
|
this.curIndex--
|
|
this.showLeftORightBtn()
|
|
this.refreshView()
|
|
}
|
|
|
|
rightClickEvent(){
|
|
Common5.playEffect("点击音效");
|
|
this.curIndex++
|
|
this.showLeftORightBtn()
|
|
this.refreshView()
|
|
}
|
|
|
|
|
|
showLeftORightBtn(){
|
|
if(this.guizeArray.length<=1){
|
|
this.leftNode.active = false
|
|
this.rightNode.active = false
|
|
}else{
|
|
if(this.curIndex == this.guizeArray.length-1){
|
|
this.leftNode.active = true
|
|
this.rightNode.active = false
|
|
}else if(this.curIndex == 0){
|
|
this.leftNode.active = false
|
|
this.rightNode.active = true
|
|
}else{
|
|
this.leftNode.active = true
|
|
this.rightNode.active = true
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// update (dt) {}
|
|
}
|
|
|