lcc-ui-sorting-group-demo/3.6.3/assets/test/scripts/test-scene.ts
2023-02-09 17:25:08 +08:00

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)])
}
}
}