| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import { _decorator, Component, game, instantiate, Label, Node, ProgressBar } from 'cc';
- import { ch_start_pack } from '../ch/start/ch_start_pack';
- import ch_sign from '../ch/sign/sign';
- import { MyGame } from './Game/MyGame';
- import { LoadRes } from './Config/LoadRes';
- const { ccclass, property } = _decorator;
- @ccclass('start')
- export class start extends ch_start_pack {
- @property(Node)
- private loadingPanel: Node = null;
- @property(Node)
- private progressBarNode: Node = null; // 进度条节点
- private totalResources: number = 17; // 总资源数,根据实际情况调整
- private loadedResources: number = 0;
- async start() {
- this.loadingPanel = this.node.getChildByName("LoadingPanel");
- this.progressBarNode = this.node.getChildByPath("LoadingPanel/ProgressBar");
- // 设置游戏帧率为60帧/秒
- game.frameRate = 60;
- if (MyGame.getInstance().getLastScene() == " ") {
- let ret = await this.try_init();
- chsdk.get_player_info();
- await MyGame.getInstance().loadData();
- ch_sign.getInstance().init(1, MyGame.getInstance().getSignData(), 7);
- MyGame.getInstance().MyPlayerInfo();
- }
- MyGame.getInstance().MyRankInfo();
- LoadRes.getInstance().setOnResourceLoaded(this.updateProgressBar.bind(this));
- LoadRes.getInstance().StartLoadRes();
- }
- //ch.
- update(deltaTime: number) {
- }
- private updateProgressBar() {
- this.loadedResources++;
- let progress = this.loadedResources / this.totalResources;
- if (this.progressBarNode && this.progressBarNode.getComponent(ProgressBar)) {
- let progressBar = this.progressBarNode.getComponent(ProgressBar);
- progressBar.progress = progress;
- if (progress == 1) {
- //移除progressBarNode节点
- this.progressBarNode.removeFromParent();
- this.loadingPanel.removeFromParent();
- let ui_Show = instantiate(LoadRes.getInstance().ui_Show);
- ui_Show.setParent(this.node);
- }
- }
- }
- }
|