Imported from yangsijun/CrownPrix (
CrownPrix/CrownPrix Watch App/Sources/HUD/AGENTS.md). Install upstream withnpx skills add yangsijun/CrownPrix --skill HUD. Copyright stays with the author.
HUD
Purpose
In-race heads-up display overlays rendered as SpriteKit nodes attached to the camera's UI layer. Shows lap timer, speed gauge, sector times, track minimap, and wrong-way warning.
Key Files
| File | Description |
|---|---|
TimerHUD.swift |
Lap timer (M:SS.mmm), speed gauge (km/h), and 3 sector time labels with color-coded backgrounds |
MinimapView.swift |
75×75 track outline with red car dot and yellow start-line marker, anchored top-right |
WrongWayIndicator.swift |
Blinking "WRONG WAY" label (3 Hz) when car heading opposes track direction by >90° |
For AI Agents
Working In This Directory
- All HUD elements are children of
CameraController.uiNode(zPosition 200) — they stay fixed on screen TimerHUDhas three states: running (incrementing), frozen (lap complete, green if PR), stopped- Speed display uses
GameConfig.displaySpeedScale(12.0) to convert internal units to km/h - Sector time format:
SS.mmmfor <60s,M:SS.mmmfor ≥60s - MinimapView downsamples track to ~80 points for performance
- WrongWayIndicator compares car heading vs track segment direction using angular difference
Testing Requirements
- Visual verification on watchOS simulator — no automated HUD tests
- Check sector color backgrounds match: white, yellow, green, purple
Common Patterns
- Final classes with SpriteKit node hierarchies
- Updated every frame by GameScene with fresh position/speed/time data
- Color constants from
SectorColorenum
Dependencies
Internal
Config/GameConfig— display scale, positioningModels/TrackData,Models/TrackPoint— minimap track outlineModels/SectorColor— sector performance color coding
External
- SpriteKit — label nodes, shape nodes, sprite rendering
