← Back to Docs
  • index.html
  • Clayground
  • Clayground.World
  • ClayWorld2d
  • Clayground 2025.2
  • ClayWorld2d QML Type

    Complete 2D game world with physics, rendering, and scene loading. More...

    Import Statement: import Clayground.World

    Detailed Description

    ClayWorld2d integrates ClayCanvas for rendering, Box2D for physics, and SVG-based scene loading into a single component. Physics bodies added as children are automatically parented to the room and configured.

    Example usage:

    import Clayground.World
    import Clayground.Physics
    
    ClayWorld2d {
        anchors.fill: parent
        xWuMax: 100; yWuMax: 50
        gravity: Qt.point(0, 10)
        observedItem: player
    
        RectBoxBody {
            id: player
            xWu: 10; yWu: 10
            widthWu: 2; heightWu: 2
            bodyType: Body.Dynamic
        }
    }

    Properties

    The rendering canvas.

    Container for all world entities.

    Whether physics simulation is running.

    Minimum X coordinate in world units.

    Maximum X coordinate in world units.

    Minimum Y coordinate in world units.

    Maximum Y coordinate in world units.

    Pixels per world unit for rendering.

    Viewport center X in world units.

    Viewport center Y in world units.

    Item the camera follows.

    The Box2D physics world.

    Gravity vector for physics.

    Physics simulation timestep.

    Whether physics is enabled.

    Base Z coordinate for loaded entities.

    Last used Z coordinate.