Files
fc/dev/project/library/imports/ac/acec9df5-94a1-44f0-904c-3d4e3d511abf.js
T

61 lines
1.6 KiB
JavaScript
Raw Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, 'acec931lKFE8JBMPU49URq/', 'cmp.item.layout');
// Scripts/mod/backpack/cmps/cmp.item.layout.js
"use strict";
/******************************************************************
*
* 简单道具列表(id,数量)
*
* 2018.05.18
******************************************************************/
cc.Class({
"extends": cc.Component,
properties: {
maxCount: {
"default": 10,
displayName: "上限"
},
fabItem: {
"default": null,
type: cc.Prefab,
displayName: "道具预制"
}
},
// 编辑器特性
editor: {
// 允许当前组件在编辑器模式下运行
executeInEditMode: false,
// 当本组件添加到节点上后,禁止同类型(含子类)的组件再添加到同一个节点,防止逻辑发生冲突
disallowMultiple: false,
// requireComponent 参数用来指定当前组件的依赖组件
requireComponent: cc.Layout
},
// 重建列表
// [[id,count]]
rebuild: function rebuild(_items) {
// 清空
if (nx.dt.arrEmpty(_items)) {
nx.pools.putChildren(this.node);
return;
}
// 重建
var pool = nx.pools.getPool(this.fabItem.name, this.fabItem);
var max = Math.min(_items.length, this.maxCount);
for (var i = 0; i < max; ++i) {
var node = this.node.children[i];
if (!node) {
node = pool.get();
node.parent = this.node;
}
var item = _items[i];
var cmp = node.getComponent("cmp.item.base");
cmp.setData(item);
}
}
});
cc._RF.pop();