mirror of
https://gitee.com/nomat/lcc-ui-sorting-group-demo.git
synced 2024-12-26 11:48:27 +00:00
29 lines
824 B
TypeScript
29 lines
824 B
TypeScript
import { _decorator, Component, Node, Prefab, SpriteFrame, instantiate } from 'cc';
|
|
import { ListTestItem } from './list-test-item';
|
|
const { ccclass, type, property } = _decorator;
|
|
|
|
@ccclass('TestScene')
|
|
export class TestScene extends Component {
|
|
|
|
@type(Prefab)
|
|
listTestItemPrefab:Prefab = null;
|
|
|
|
@type(Node)
|
|
listContent:Node = null;
|
|
|
|
@type([SpriteFrame])
|
|
flagSpriteFrames:SpriteFrame[] = [];
|
|
|
|
@property
|
|
listItemMax:number = 200;
|
|
|
|
start() {
|
|
for(let i = 0; i < this.listItemMax; i++){
|
|
let node = 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)])
|
|
}
|
|
}
|
|
}
|