Repository navigation
Mask transitions shaped like an image or a sprite, closing on the player (#1399) - #1894
Merged
Merged
Conversation
…yer (#1399) - MaskEffect, state.transition("mask") and Trigger take as shape an image, the name of a preloaded one, or a Sprite (the frame it shows when the transition starts, facing its way). The silhouette is made solid: faint pixels count in full and gaps inside the outline are filled - center closes the mask on a renderable or a screen point, and the reveal opens from the same place; invert makes the shape the cover, growing out of that point. state.transition takes them as a fifth argument - On a Trigger, shape and center "touching" stand for whoever walked in, usable from Tiled properties - The reveal reuses the silhouette and point the hide settled, so the state change destroying the player in between is fine - Every shape grows until the screen is wholly inside it, so a reveal ends uncovered: a Polygon mask no longer jumps open at the last frame - Drawn with plain images and fills, the same on Canvas, WebGL and WebGPU - Platformer example: the door closes the player's own silhouette onto it - Skills, changelog, TSDoc examples; melonJS 20.17.0 (unreleased) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
- A shape grows about its thickest part (a distance transform of the silhouette, or the deepest point of a polygon not around its origin), so a U, a crescent or a sprite drawn off-centre still ends with the screen uncovered; a fully transparent image or frame warns and is an iris - A center in a floating container is read on the screen (isFloating), and under a Camera3d at its absolute depth - A shape that is not an Ellipse, Polygon, image, name or Sprite warns that it is not supported; no shape at all is the default iris - state.transition lets go of a sprite or renderable once the hide has read it, so a later change never reads a destroyed or recycled player - Sprite#drawFrame(target, x, y) holds the frame placement Sprite#draw and the silhouette share; NineSliceSprite draws through it, so its silhouette is its full size and it now honours flicker() - MaskEffect#reverseOptions() gives the settings of the effect played back, used by state.transition and Trigger; MaskEffectOptions is exported - One CanvasRenderTarget setup for the silhouette and the cover - Tests: off-centre and empty silhouettes, off-origin and inverted polygons, nearly closed draws, floating and Camera3d centers, flips on both axes, turned and trimmed atlas frames, nine-slice, unreadable images, the Trigger reveal, a pixel check at the end of a state transition, and the later change after the player is gone Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
…is internal (#1399) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JnzwA4a7ZyjLBpbeEpFLu6
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.
Description
Mask transitions can now use an image or a sprite as the mask, not only an
Ellipseor aPolygon. They can also close on a chosen point and be inverted.shape(onMaskEffect,state.transition("mask", …)andTrigger) now also takes:Sprite: the frame it shows when the transition starts, flipped the way it is drawn.The image's alpha is the silhouette, made solid: faint pixels count in full, and enclosed gaps such as eyes are filled. With no
shape,MaskEffectuses an iris.centeris where the mask closes and the reveal opens. It takes a renderable, read once on screen when the transition starts (it handles floating containers andCamera3ddepth), or a screen point.invertmakes the shape the cover: filled with the colour, it grows to hide the scene.Trigger: settingshapeorcenterto"touching"means whoever set the trigger off, so a level door can be configured from Tiled properties alone.How it behaves:
state.transitionlets go of the sprite: a sprite or renderable is let go after one transition, so later changes never read a destroyed or recycled object.Shared code:
Sprite#drawFrame(target, x, y)(internal) now holds the frame placement thatSprite#drawand the silhouette both use.NineSliceSpritedraws through it too. As a side effect it now honoursflicker(), which it used to ignore.MaskEffect#reverseOptions()builds the reveal for bothstate.transitionandTrigger.Also in this PR:
Type of change
Checklist
pnpm lintpasses)pnpm testpasses)pnpm build)The full engine suite passes (11,427 tests). The two new spec files cover image, sprite and atlas silhouettes,
center,invert, the fallbacks, theTriggerreveal, and the fullstate.transitionpath, including a pixel check at the end of the reveal.Related issues
Closes #1399
Generated by Claude Code