Roku And Web Host Integration
Game scenes should not own platform setup. The host shell creates the screen, runtime services, input adapters, audio manager, asset bundle states, and controller pairing manager, then passes a context into the selected game.
Host Responsibilities
| Host responsibility | Why it stays outside scenes |
|---|---|
Create GameRuntime | Owns tick, present/swap, input drain, audio tick, debug overlays. |
| Create platform screen/compositor | Platform-specific rendering setup. |
| Register input adapters | Roku remote, web, keyboard/gamepad, paired controls. |
| Load asset bundle states | Scenes consume ready states; host owns downloads/cache lifecycle. |
| Register audio resources | Platform-specific Roku/web audio resource setup. |
| Start paired-control server | Pairing manager is shared by scenes and adapters. |
Drive TimerService._tick(deltaMs) | Required for HsPromise, port promises, fetch, and bundle work. |
Runtime Setup Shape
The Roku game sample host creates:
BaseGameApp- platform screen and compositor
GameInputAdapterManagerRokuGameInputAdapterHs2dControlInputManagerPairedControlsInputAdapterAudioManagerGameRuntime- selected Hs2d game controller
Scenes receive a game/example context rather than constructing host services themselves.
Asset Bundle States
The host loads bundle states before examples resolve assets. A game scene should resolve bundle keys through the context helper and keep package fallbacks for local runs.
resolveGameAssetBundleUri(context, 'my-game', 'my-game.images.player', fallbackUri);
Do not make scenes fetch bundle manifests directly.
Audio Registration
Register platform audio resources from ready bundle manifests in the host layer. Then pass the shared AudioManager into scenes that need music or SFX.
Input Registration
Input adapters feed the runtime. Scenes consume normalized GameInput[] from update(deltaMs, inputs).
The pairing server and paired-controls adapter should be attached once at host setup. Pause menus then push pairing scenes that operate on the same Hs2dControlInputManager.
Source References
| Source | What it shows |
|---|---|
../hosanna-ui-game-samples-public/src/sample-platform/roku-game/hs-game-main.ts | Full Roku game host setup. |
GameRuntime.ts | Runtime tick and controller handoff. |
RokuGameAudioManager.ts | Roku audio resource registration. |
WebGameAudioManager.ts | Web audio resource registration. |
PairedControlsInputAdapter.ts | Control manager integration into game input. |