import { _decorator, Component, director, Node, resources, SceneAsset, Sprite } from 'cc'; const { ccclass, property } = _decorator; @ccclass('Loading') export class Loading extends Component { @property(Node) RankNode: Node = null; @property(Node) StartNode: Node = null; @property(Node) SliderNode: Node = null; protected onLoad(): void { this.init() this.Startloading() } init() { this.RankNode.active = false; this.StartNode.active = false; this.SliderNode.active = true; this.SliderNode.getComponentInChildren(Sprite).fillRange = 0; } Startloading() { resources.preloadScene('Game', (finished: number, total: number) => { if ((finished / total) > this.SliderNode.getComponentInChildren(Sprite).fillRange) { this.SliderNode.getComponentInChildren(Sprite).fillRange = finished / total; } } , (err) => { if (err) { console.error(err); return; } this.OverLoading() console.log('预加载场景成功'); }) } OverLoading() { this.SliderNode.active = false; this.StartNode.active = true; this.RankNode.active = true; } ClickGame() { director.loadScene('Game', (err) => { if (err) { console.error(err); return; } console.log('加载场景成功'); }) } ClickRank() { console.log('点击排行榜'); } }