M5-M7: сцены, лобби, экран игры и цикл матча
Обе сцены собраны через Code Mode, не руками. - loader: поднимает модули, прогревает арт карт, уходит в lobby - lobby: обе UI-ветки в одной сцене (по ARCHITECTURE.md), матч — это смена видимого корня, а не загрузка сцены - GameScreen рисует текущее состояние и доводит узлы твинами, а не проигрывает поток событий: узел карты живёт вместе со своей картой, поэтому "шестёрка ушла из руки на стол" не требует отдельного случая - один тап = ход целиком; логика вынесена в core/rules/intent.ts и покрыта тестами, в том числе проверкой, что она никогда не предложит ход, который правила отвергнут - арт карт переехал в assets/resources: .pac — это инструкция упаковки на сборке, а не рантайм-ассет, и без ссылок на кадры в сборку не попадало ничего. Теперь все 37 спрайтов в одной текстуре 2048x2048 - клики кнопок подписываются в коде, а не через clickEvents сцены - строки интерфейса собраны в одном файле Сборка web-mobile проходит чисто, все ссылки в сцене проверены. Вживую не запускалось: браузер в этом окружении не поднимает главный цикл движка. Подробности — в docs/TECHNICAL.md. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user