// Learn cc.Class: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html // Learn Attribute: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html cc.Class({ extends: cc.Component, properties: { //商品名称 commodityName: { default: null, type: cc.Label, }, //商品价格 commodityPrice: { default: null, type: cc.Label, }, //商品材料 commodityMaterial: { default: null, type: cc.Label, }, //记录当前商品的信息 commodity: { default: null, visible: false, }, }, updateItem: function (tmplId, itemId, commodity) { // cc.log('设置食物种类', commodity); this.commodity = commodity; // goodsId: 0 // goodsMaterial: goodsMaterialClass {crops: 2, wood: 0, mineral: 0} // goodsName: "方便面" // goodsPrice: 50 // goodsSalesRate: 70 this.commodityName.string = commodity.goodsName; this.commodityPrice.string = commodity.goodsPrice; this.commodityMaterial.string = '农:'+commodity.goodsMaterial.crops+' 木:'+commodity.goodsMaterial.wood }, });