feat: 提交资源

This commit is contained in:
han_han9
2025-10-28 21:55:41 +08:00
parent 591f398085
commit 55c4fcd9ae
2146 changed files with 172747 additions and 456 deletions

View File

@@ -0,0 +1,79 @@
import { _decorator, Component, Label, ProgressBar } from "cc";
const { ccclass, property } = _decorator;
@ccclass("HotupdateLoading")
export class HotupdateLoading extends Component {
@property(Label)
label: Label = null;
@property(ProgressBar)
progressBar: ProgressBar = null;
/** 动画定时器ID */
private animationTimer: NodeJS.Timeout | null = null;
/** 当前动画状态 */
private animationState: number = 0;
/** 动画基础文本 */
private baseText: string = "";
protected onDestroy() {
this.stopTextAnimation();
}
public updateProgress(current: number, total: number) {
this.progressBar.progress = current / total;
this.progressBar.node.active = true;
this.label.string = `正在更新中 ${current}/${total}`;
}
public updateProgressText(text: string, enableAnimation: boolean = false) {
this.stopTextAnimation();
if (enableAnimation) {
this.startTextAnimation(text);
} else {
this.label.string = text;
}
this.progressBar.node.active = false;
}
/**
* 开始文本动画
* @param baseText 基础文本,如"加载中"
* @param interval 动画间隔时间默认500毫秒
*/
public startTextAnimation(baseText: string, interval: number = 500) {
this.stopTextAnimation();
this.baseText = baseText;
this.animationState = 0;
// 立即显示第一帧
this.updateAnimationText();
// 启动定时器
this.animationTimer = setInterval(() => {
this.animationState = (this.animationState + 1) % 4; // 0,1,2,3 循环
this.updateAnimationText();
}, interval);
}
/**
* 停止文本动画
*/
public stopTextAnimation() {
if (this.animationTimer !== null) {
clearInterval(this.animationTimer);
this.animationTimer = null;
}
}
/**
* 更新动画文本显示
*/
private updateAnimationText() {
const dots = ".".repeat(this.animationState);
this.label.string = this.baseText + dots;
}
}