← Back to Docs
  • index.html
  • Clayground
  • Clayground.Physics
  • VisualizedPolyBody
  • Clayground 2025.2
  • VisualizedPolyBody QML Type

    Polygon-shaped physics body with Canvas visualization. More...

    Import Statement: import Clayground.Physics

    Detailed Description

    VisualizedPolyBody combines a visual Poly shape with a Box2D polygon fixture. The physics shape automatically synchronizes with the visual vertices.

    Example usage:

    import Clayground.Physics
    import Box2D
    
    VisualizedPolyBody {
        canvas: myCanvas
        vertices: [
            {x: 0, y: 0},
            {x: 2, y: 0},
            {x: 1, y: 2}
        ]
        fillColor: "green"
        bodyType: Body.Dynamic
        density: 2
    }

    Properties

    The Box2D body instance.

    The Box2D polygon fixture.

    Physics world reference.

    Fixture density.

    Friction coefficient.

    Bounciness coefficient.

    If true, detects collisions without physical response.

    Collision category bits.

    Collision mask bits.

    Collision group index.

    Methods

    Refreshes visual and physics geometry from vertices.