skills: align physics, UI and pooling with the source; fix the platformer's dead z - #1668
Merged
Merged
Conversation
Checked the platformer example against the skills, taking the engine
source as the authority. Three gaps, and one thing I had previously got
wrong.
- physics: `setMaxVelocity` and `setFriction` appeared in no skill, though
`maxVel` is what turns `body.force` into a speed and the movement
section already showed `force.x = maxVel.x`. Both are current, and both
take an optional third argument for the depth axis
- ui: the skill's description promises `UISpriteElement` but its body
never named the handlers. Documents `onClick` / `onRelease` / `onOver` /
`onOut` / `onHold`, that a `false` return stops propagation, and that
the pointer only reaches an element whose `isKinematic` is false —
which `UIBaseElement` and `UISpriteElement` clear themselves
(uibaseelement.ts:86, uispriteelement.ts:95)
- performance: CORRECTION. A previous commit claimed `pool.pull("me.Tween")`
named something never registered, and rewrote the line to say registered
names carry no `me.` prefix. Both claims are false: `pool.register`
aliases every name under an `me.` prefix pointing at the same entry, in
the pool AND the Tiled object factory (legacy_pool.js:87-97). That is
why a map authored against 1.x still resolves its classes. Both spellings
work; the unprefixed one is canonical
Deliberately NOT propagated from the example: its platform and slope
handling uses `response.overlapV` / `response.overlap`, which the physics
skill correctly marks deprecated in favour of `depth` / `normal`. The
skill documents the current adapter API; the example is legacy there.
Likewise its `game.world` usage and `this.z = Number.POSITIVE_INFINITY`,
both of which the skills already call out as wrong.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NGvtaUNATVCVxD2qcbiY4t
…xist `this.z = Number.POSITIVE_INFINITY` on the HUD container and the virtual joypad, with the comment "make sure our object is always draw first". `Renderable` has no `z` property — the accessor is `depth`, an alias for `pos.z` — so both assignments only ever created an expando nothing read, and the two containers were ordered by the world's `autoDepth` instead. It looked right by accident. Both now take their order from an explicit `addChild(child, HUD_Z)` in `play.ts`, which is what the ui skill has been telling readers to do while this example demonstrated the opposite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NGvtaUNATVCVxD2qcbiY4t
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checked the platformer example against the skills, taking the engine source as the authority. Three skill gaps, one correction to a claim I made earlier, and one real defect in the example.
Correction to a claim in #1665
A commit in that PR claimed
melonjs-performance'spool.pull("me.Tween")named something that was never registered, and rewrote the line to state that registered names carry nome.prefix.Both claims are false.
legacy_pool.js:87-97:Every
pool.registeraliases its name under anme.prefix pointing at the same entry — in the pool and in the Tiled object factory. That is why a map authored against melonJS 1.x still resolves its classes, and why the platformer'spool.register("me.Trigger", …)correctly matches its map object of that name. Both spellings work; the unprefixed one is canonical. The skill now says so, and says not to "correct" anme.-prefixed name.setMaxVelocity/setFrictionwere in no skillmaxVelis what turnsbody.forceinto a speed, and the movement section already showedthis.body.force.x = this.body.maxVel.x— with nothing on howmaxVelgets set. Both setters are current (no@deprecated), and both take an optional third argument for the depth axis, left unchanged when omitted.UISpriteElementhandlers were undocumentedThe skill's description promises
UISpriteElement/UITextButton; its body never named the handlers. Now documentsonClick/onRelease/onOver/onOut/onHold, that afalsereturn stops propagation, and that the pointer only reaches an element whoseisKinematicis false — whichUIBaseElementandUISpriteElementclear themselves (uibaseelement.ts:86,uispriteelement.ts:95).The example demonstrated the opposite of the ui skill
this.z = Number.POSITIVE_INFINITYon the HUD container and the virtual joypad, commented "make sure our object is always draw first".Renderablehas nozproperty — the accessor isdepth, an alias forpos.z— so both assignments created an expando nothing read, and the containers were ordered by the world'sautoDepth. It looked right by accident. Both now take their order from an explicitaddChild(child, HUD_Z)inplay.ts.Verified in Chrome: HUD controls and minimap render over the level, no page errors.
Deliberately not propagated from the example
The platformer is legacy in two further places the skills already get right, so the skills were left alone:
response.overlapV/response.overlap, which the physics skill correctly marks deprecated in favour ofdepth/normalgame.world/game.viewport, where the migration skill already documentsparentAppand theApplicationparameter🤖 Generated with Claude Code
https://claude.ai/code/session_01NGvtaUNATVCVxD2qcbiY4t