第一次

This commit is contained in:
lujun
2023-02-05 20:31:26 +08:00
commit fe21ffdc65
66 changed files with 8178 additions and 0 deletions

View 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);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "bdab2938-c9ff-4c3d-9536-23744a5e1c82",
"files": [],
"subMetas": {},
"userData": {}
}

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

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "bd7060b3-1793-49c7-8598-3cf79d73d63f",
"files": [],
"subMetas": {},
"userData": {}
}