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

43 lines
988 B
JavaScript

var gameConfig = require("gameConfig")
var Utils = require("Utils");
cc.Class({
extends: cc.Component,
properties: {
lb_count: {
default: null,
type: cc.Label
},
sp_icon: {
default: null,
type: cc.Sprite
},
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
initdata(id, cost, needcheck) {
Utils.setitem(this, id, this.sp_icon)
this.lb_count.node.color = cc.Color.WHITE
if (needcheck) {
var count = cc.playerData.getItemCount(id)
this.lb_count.string = count + "/" + cost
if (count < cost) {
this.lb_count.node.color = cc.Color.RED
}
} else {
this.lb_count.string = cost
}
},
initdata2(sv, needcheck) {
var arr = sv.split(':')
this.initdata(arr[0], arr[1], needcheck)
}
// update (dt) {},
});