Skip to content

draw2D: no way to choose which shape is drawn on top #31

Open

Description

@Exeloo

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.

Other context

No response

Activity

  1. added
    enhancement
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions