mirror of
https://gitee.com/nomat/lcc-ui-sorting-group-demo.git
synced 2025-10-25 01:25:26 +00:00
第一次
This commit is contained in:
37
assets/test/scripts/list-test-item.ts
Normal file
37
assets/test/scripts/list-test-item.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { _decorator, Component, Node, Label, ProgressBar, Sprite, SpriteFrame, UIOpacity } from 'cc';
|
||||
const { ccclass, type } = _decorator;
|
||||
|
||||
@ccclass('ListTestItem')
|
||||
export class ListTestItem extends Component {
|
||||
|
||||
@type(Label)
|
||||
rankText:Label = null;
|
||||
|
||||
@type(Label)
|
||||
goldText:Label = null;
|
||||
|
||||
@type(Sprite)
|
||||
flagImage:Sprite = null;
|
||||
|
||||
@type(Label)
|
||||
levelText:Label = null;
|
||||
|
||||
@type(ProgressBar)
|
||||
levelBar:ProgressBar = null;
|
||||
|
||||
@type(Label)
|
||||
descText:Label = null;
|
||||
|
||||
@type(UIOpacity)
|
||||
uiOpacity:UIOpacity = null;
|
||||
|
||||
randomData(index:number, flagSpriteFrame:SpriteFrame){
|
||||
this.rankText.string = String(index);
|
||||
this.goldText.string = String(Math.floor(1000 + Math.random()* 1000));
|
||||
this.flagImage.spriteFrame = flagSpriteFrame;
|
||||
this.levelText.string = `lv.${Math.floor(Math.random()* 100)}`;
|
||||
this.levelBar.progress = Math.random();
|
||||
this.descText.string = `什么也没留下 - ${index}`;
|
||||
this.uiOpacity.opacity = 100 + Math.floor(Math.random() * 155);
|
||||
}
|
||||
}
|
||||
9
assets/test/scripts/list-test-item.ts.meta
Normal file
9
assets/test/scripts/list-test-item.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "bdab2938-c9ff-4c3d-9536-23744a5e1c82",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
28
assets/test/scripts/test-scene.ts
Normal file
28
assets/test/scripts/test-scene.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
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)])
|
||||
}
|
||||
}
|
||||
}
|
||||
9
assets/test/scripts/test-scene.ts.meta
Normal file
9
assets/test/scripts/test-scene.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "bd7060b3-1793-49c7-8598-3cf79d73d63f",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
||||
Reference in New Issue
Block a user