mirror of
https://gitee.com/nomat/lcc-ui-sorting-group-demo.git
synced 2025-11-13 10:47:40 +00:00
实现2.4.11版本
This commit is contained in:
43
2.4.11/assets/test/scripts/list-test-item.ts
Normal file
43
2.4.11/assets/test/scripts/list-test-item.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
// Learn TypeScript:
|
||||
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
|
||||
// Learn Attribute:
|
||||
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
|
||||
// Learn life-cycle callbacks:
|
||||
// - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
|
||||
|
||||
const {ccclass, property} = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class ListTestItem extends cc.Component {
|
||||
|
||||
@property({type: cc.Label})
|
||||
rankText:cc.Label = null;
|
||||
|
||||
@property({type: cc.Label})
|
||||
goldText:cc.Label = null;
|
||||
|
||||
@property({type: cc.Sprite})
|
||||
flagImage:cc.Sprite = null;
|
||||
|
||||
@property({type: cc.Label})
|
||||
levelText:cc.Label = null;
|
||||
|
||||
@property({type: cc.ProgressBar})
|
||||
levelBar:cc.ProgressBar = null;
|
||||
|
||||
@property({type: cc.Label})
|
||||
descText:cc.Label = null;
|
||||
|
||||
@property({type: cc.Node})
|
||||
uiOpacity:cc.Node = null;
|
||||
|
||||
randomData(index:number, flagSpriteFrame:cc.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);
|
||||
}
|
||||
}
|
||||
10
2.4.11/assets/test/scripts/list-test-item.ts.meta
Normal file
10
2.4.11/assets/test/scripts/list-test-item.ts.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"uuid": "9f5387d6-696a-4491-82ea-1a443403ed3c",
|
||||
"importer": "typescript",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
28
2.4.11/assets/test/scripts/test-scene.ts
Normal file
28
2.4.11/assets/test/scripts/test-scene.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
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)])
|
||||
}
|
||||
}
|
||||
}
|
||||
10
2.4.11/assets/test/scripts/test-scene.ts.meta
Normal file
10
2.4.11/assets/test/scripts/test-scene.ts.meta
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"uuid": "66495605-543c-44a7-b208-dfc48bdce8b8",
|
||||
"importer": "typescript",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
Reference in New Issue
Block a user