Refresh whack-a-mole example for v19 API#1374
Conversation
- ExampleWhacAMole.ts: replace video.init() with new Application() - HUD.ts: replace standalone font.draw() (removed in #1364) with BitmapText children added to HUDContainer - play.ts: type onResetEvent/onDestroyEvent with Application parameter, use app reference instead of game singleton Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates the whac-a-mole example to align with the melonJS v19+ API by switching to the Application entry point and modernizing HUD rendering to avoid deprecated standalone BitmapText.draw() usage.
Changes:
- Replace legacy
video.init()startup withnew Application(...)in the example entry point. - Refactor HUD score rendering from a custom
Renderableusing standalone font drawing toBitmapTextinstances added as HUD children. - Update
PlayScreento use theappinstance (app.reset(),app.world) instead of the globalgamesingleton in the stage lifecycle hooks.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| packages/examples/src/examples/whac-a-mole/ExampleWhacAMole.ts | Switches example startup to new Application(...) instead of video.init(). |
| packages/examples/src/examples/whac-a-mole/play.ts | Migrates stage lifecycle logic to use the Application instance (app) for reset/world operations. |
| packages/examples/src/examples/whac-a-mole/HUD.ts | Replaces custom score Renderable + standalone draw calls with BitmapText children updated over time. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| export class PlayScreen extends Stage { | ||
| /** | ||
| * action to perform on state change | ||
| */ | ||
| onResetEvent() { | ||
| game.reset(); | ||
| override onResetEvent(app) { | ||
| app.reset(); |
There was a problem hiding this comment.
onResetEvent's app parameter is implicitly any, which fails the examples TS config (strict/noImplicitAny). Also this.HUD is assigned later but the PlayScreen class doesn't declare a HUD field, which will be a TypeScript error (Property 'HUD' does not exist on type 'PlayScreen'). Type the parameter as Application and add a typed HUD class property (optionally HUD?: HUDContainer if it can be absent).
- play.ts: add Application type to onResetEvent/onDestroyEvent, declare HUD property, fix MoleManager constructor call (no args) - HUD.ts: cache last score/hiscore to avoid per-frame setText overhead, fix misleading "draw first" comment Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
video.init()withnew Application()entry pointfont.draw()(removed in Remove deprecated standalone draw for Text/BitmapText and UITextButton compat #1364) withBitmapTextchildren added directly to the HUD containeronResetEvent/onDestroyEventwithApplicationparameterTest plan
🤖 Generated with Claude Code