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

67 lines
1.5 KiB
JavaScript

var SDKManage = require("SDKManage")
var gameConfig = require("gameConfig")
var Utils = require("Utils")
cc.Class({
extends: cc.Component,
properties: {
lb_count: {
default: null,
type: cc.Label,
},
sp_pz: {
default: null,
type: cc.Sprite,
},
sp_icon: {
default: null,
type: cc.Sprite
},
nd_chosed: {
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.nd_chosed.active = false
this.itemid = v.item_id
this.lb_count.string = v.item_num
Utils.setitem(this, this.itemid, this.sp_icon, this.sp_pz)
},
onclick() {
cc.Notifier.emit("choseitembag", {
itemid: this.itemid,
})
},
choseitembag(v) {
if (this.itemid == v.itemid) {
this.nd_chosed.active = true
} else {
this.nd_chosed.active = false
}
},
onDisable() {
cc.Notifier.off('choseitembag', this);
this.inited = false
},
onEnable() {
if (!this.inited) {
cc.Notifier.on('choseitembag', this, this.choseitembag.bind(this));
this.inited = true
}
},
// update (dt) {},
});