SamsaraGame/assets/Script/game/ActiveDetailUI.js

52 lines
1.7 KiB
JavaScript
Raw Permalink Normal View History

2025-04-24 17:03:28 +08:00

import ItemUtil from "../ts/core/ItemUtil";
import SKUIUtil from "../ts/gear_2.3.4/util/SKUIUtil";
let CPubFunction = require('./PubFunction');
cc.Class({
extends: cc.Component,
properties: {
},
onLoad() {
this.vecPrizeIcon = [];
},
start() {
cc.find('btnClose', this.node).getComponent(cc.Button).clickEvents.push(CPubFunction.CreateEventHandler(this.node, "ActiveDetailUI", "Close", 0));
},
loadInfo(strTitle, strInfo, mapPrize) {
cc.find(`picText/Title`, this.node).getComponent(cc.Label).string = strTitle;
let goLabInfo = cc.find(`labInfo`, this.node);
let goLayoutPeize = cc.find('LayoutPrize', this.node);
let label=goLabInfo.getComponent(cc.Label);
label.getComponent(cc.Label).string = strInfo;
let labelH = SKUIUtil.labelHeightBy(label);
let offsetY=label.node.y - labelH - 10;
goLayoutPeize.y = offsetY;
this.node.height = 500;
this.node.y = this.node.height / 2;
SKUIUtil.destroyList(this.vecPrizeIcon);
cc.loader.loadRes(`Prefabs/preItem`, cc.Prefab, (err, prefab) => {
let nIndex = -1;
for (var it in mapPrize) {
nIndex++;
let nX = 40 + (nIndex % 5) * 70;
let nY = -33 - Math.floor(nIndex / 5) * 70;
let goPrizeIcon = SKUIUtil.createSubNode(goLayoutPeize, cc.v2(nX, nY), prefab, 'preItem');
let stConfigInfo = ItemUtil.getItemData(it);
cc.find('Icon', goPrizeIcon).getComponent(cc.Sprite).spriteFrame = ItemUtil.getItemIcon(stConfigInfo.icon);
this.vecPrizeIcon.push(goPrizeIcon);
}
});
},
Close() {
this.node.destroy();
},
});