Skip to main content

CoordPlane

Enum representing the coordinate plane for the position 2D vector in the TransformComponent

Index

Enumeration Members

Enumeration Members

Screen

Screen: screen

The screen coordinate plane represents screen space, entities drawn in screen space are pinned to screen coordinates ignoring the camera.

Screen space is rooted at the top-left of the safe Screen.contentArea (the "C-frame"): a CoordPlane.Screen entity with pos = (0, 0) is drawn at contentArea.topLeft, not at the raw canvas corner (the "R-frame"). The engine applies this shift automatically before drawing — see Screen.contentAreaOffset.

Under display modes that don't clip (DisplayMode.Fixed, DisplayMode.FitScreen, DisplayMode.FillScreen, DisplayMode.FitContainer, DisplayMode.FillContainer) contentAreaOffset = (0, 0) so the C and R frames coincide. Under DisplayMode.FitScreenAndFill / DisplayMode.FitContainerAndFill / DisplayMode.FitScreenAndZoom / DisplayMode.FitContainerAndZoom, the C-frame is shifted into the safe area.

  World (infinite, camera)         Screen (CoordPlane.Screen, C)       Canvas / resolution (R)

    +                                    +                                 +
    | camera moves this                  | (0,0) = contentArea.topLeft     | (0,0) = canvas top-left
    |                                    |   shifts into the safe area     |   raw canvas corner
    |                                    |   on *AndFill / *AndZoom        |
    v                                    v                                 v
                                  +----------- contentW -----------+     +----------- resolutionW -------------------+
  worldToScreen():                |                                |     |         |                        |        |
  camera.transform                |        contentArea             |     | unsafe  |     contentArea        | unsafe |
  - contentAreaOffset  ========>  |     (CoordPlane.Screen)        | <== | (clip)  |       (R span)         | (clip) |
                                  |                                |     |         |                        |        |
  screenToWorld():                +-------------------------------_+     +-------------------------------------------+
  camera.inverse
  + contentAreaOffset

  contentAreaOffset = (clip|0, clip|0)   on the *AndFill / *AndZoom horizontal-clip axis;
                        (0, 0)    under Fixed/FitScreen/FillScreen/FitContainer/FillContainer.

Use Screen.worldToScreenCoordinates, Screen.screenToWorldCoordinates, Screen.pageToScreenCoordinates and Screen.screenToPageCoordinates to convert between frames — they perform the offset and camera math for you.

World

World: world

The world coordinate plane (default) represents world space, any entities drawn with world space move when the camera moves.

Page Options