import { _decorator, Component, director, game, resources, SpriteFrame } from 'cc'; import { App } from './App'; import { CARDS_DIR } from '../ui/game/CardLibrary'; const { ccclass, property } = _decorator; /** * The loader scene, per ARCHITECTURE.md: bring the modules up, then hand over * to the lobby. Everything that must exist before any gameplay runs belongs * here, and nowhere else. */ @ccclass('Bootstrap') export class Bootstrap extends Component { @property({ tooltip: 'Scene to open once the modules are ready.' }) nextScene = 'lobby'; start(): void { // A phone that throttles to 30 fps makes the card animations stutter; // asking for 60 up front is cheap and the engine falls back on its own. game.frameRate = 60; App.create(); // Warm the card art here rather than on the first deal: thirty-seven // sprites are the only sizeable load in the game, and a loader scene is // exactly where a player expects to wait for it. resources.loadDir(CARDS_DIR, SpriteFrame, (error) => { if (error) { console.error('[bootstrap] could not preload the card art', error); } this._openLobby(); }); } private _openLobby(): void { director.loadScene(this.nextScene, (error) => { if (error) { console.error(`[bootstrap] could not open '${this.nextScene}'`, error); } }); } }