From acaaa697a41c31bd30b7d3d7fcc4c4bbb028a48b Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Nov 2026 09:10:32 +0000 Subject: [PATCH 1/2] Container: a reset keeps the sort pending for the children it keeps Adding a child queues a sort for the next tick. Container#reset cancelled that sort, then removed every child that is not persistent, so the persistent ones it kept stayed in the order they were added, their depth ignored, until something else sorted the container. A screen that adds its persistent objects and loads a level straight away got exactly that, since level.load resets the world: a background added first was drawn over everything. reset() now sorts again when a sort was pending and children remain. destroy() does not: it goes through clearChildren alone. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01JnzwA2BZwXkRJLpNxCXBNt --- packages/melonjs/CHANGELOG.md | 1 + .../melonjs/skills/melonjs-tilemaps/SKILL.md | 1 + packages/melonjs/src/renderable/container.js | 11 ++ .../tests/container-reset-sort.spec.js | 174 ++++++++++++++++++ 4 files changed, 187 insertions(+) create mode 100644 packages/melonjs/tests/container-reset-sort.spec.js diff --git a/packages/melonjs/CHANGELOG.md b/packages/melonjs/CHANGELOG.md index 591826775..7023c8cc3 100644 --- a/packages/melonjs/CHANGELOG.md +++ b/packages/melonjs/CHANGELOG.md @@ -23,6 +23,7 @@ - UI: `UITextButton#bitmapText`, for `label` ### Fixed +- Container: `reset()` keeps the sort pending for the persistent children it keeps. It cancelled it, so objects a screen added just before a `level.load` stayed in the order they were added, their depth ignored: a background added first was drawn over everything - Particles: particles are on their emitter's `visibilityLayer`, and follow a change to it. They stayed on layer 1, so a camera whose `cullMask` drew only the emitter's layer drew none of its particles - Loader: assets on the game's own origin are requested with its cookies and HTTP auth, so a game behind a login no longer gets a 403 for every asset ([#1801](https://github.com/melonjs/melonJS/issues/1801)) - Loader: an asset on another origin loads whenever its server allows it (CORS), without `crossOrigin`, and one it does not allow fails at load with an error naming it, instead of later with "Unexpected end of input" or "The source image could not be decoded". `crossOrigin` now only applies to the `