pubgv3/assets/scripts/UI/battlematch/battlechoseone.js
zhuguoqing ff550d5d6a init
2022-05-22 10:32:02 +08:00

75 lines
1.9 KiB
JavaScript

var SDKManage = require("SDKManage")
var gameConfig = require("gameConfig")
cc.Class({
extends: cc.Component,
properties: {
lb_name: {
default: null,
type: cc.Label,
},
sp_icon: {
default: null,
type: cc.Sprite,
},
nd_chose: {
default: null,
type: cc.Node,
},
nd_weijiesuo: {
default: null,
type: cc.Node,
},
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
initdata(v) {
if (v != 0) {
this.node.active = true
} else {
this.node.active = false
return
}
this.hero_id = v
var self = this
var cfg = gameConfig.playerConfig[v]
cc.loader.loadRes("textures/headIcon/" + cfg.icon, cc.SpriteFrame, function(err, res) {
if (!err && self.isValid) {
self.sp_icon.spriteFrame = res;
}
});
this.lb_name.string = cfg.name
this.nd_weijiesuo.active = false
//this.hasget = cc.playerData.checkhasgethero(v)
// this.nd_weijiesuo.active = !this.hasget
this.nd_chose.active = false
},
onclick() {
cc.Notifier.emit("battleclickchose",{
account_id:SDKManage.account_id,
hero_id:this.hero_id,
hero_skin:cc.playerData.getheroSkinidbyId(this.hero_id,0)
})
this.nd_chose.active = true
},
battleclickchose(){
this.nd_chose.active = false
},
onDisable() {
cc.Notifier.off('battleclickchose', this);
this.inited = false
},
onEnable() {
if (!this.inited) {
cc.Notifier.on('battleclickchose', this, this.battleclickchose.bind(this));
this.inited = true
}
},
// update (dt) {},
});