mirror of
https://gitee.com/nomat/lcc-ui-sorting-group-demo.git
synced 2025-01-13 22:51:03 +00:00
29 lines
779 B
TypeScript
29 lines
779 B
TypeScript
import ListTestItem from "./list-test-item";
|
|
|
|
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export class TestScene extends cc.Component {
|
|
|
|
@property({type:cc.Prefab})
|
|
listTestItemPrefab:cc.Prefab = null;
|
|
|
|
@property({type:cc.Node})
|
|
listContent:cc.Node = null;
|
|
|
|
@property({type:[cc.SpriteFrame]})
|
|
flagSpriteFrames:cc.SpriteFrame[] = [];
|
|
|
|
@property
|
|
listItemMax:number = 200;
|
|
|
|
start() {
|
|
for(let i = 0; i < this.listItemMax; i++){
|
|
let node = cc.instantiate(this.listTestItemPrefab);
|
|
node.parent = this.listContent;
|
|
let item = node.getComponent(ListTestItem);
|
|
item?.randomData(i + 1, this.flagSpriteFrames[Math.floor(Math.random() * this.flagSpriteFrames.length)])
|
|
}
|
|
}
|
|
}
|