You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
draw2D: no way to choose which shape is drawn on top #31
Which package or utils is this feature request for?
systems
Feature
draw2D (graphics-2d) gives a game no way to choose which shape is drawn on top when two overlap. It adds rectangles, then circles, then texts, each in entity order (draw-2d.ts#L29-L39), so a game can't put a rectangle over a circle or a text, and the order of two rectangles depends on their entity ids. Scenes reuse freed ids, so after a scene loads again a background can end up over a sprite.
flappy-bird and tic-tac-toe in NanoForge-dev/examples#18 work around it with their own DrawOrder2D component and system, which re-stack the Konva nodes (shared/arcade), and raid-survival sorts its sprites the same way.
Ideal solution or implementation
A z (or zIndex) on the drawables, or a DrawOrder2D component, that draw2D honours: higher z drawn over lower, ties kept in a stable order. Only re-stack when a z changes or a shape is added.
Alternative solutions or implementations
Ship the examples' DrawOrder2D component and system as they are, in graphics-2d.
Activity