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

    Base component for physics-enabled items with world unit support. More...

    Import Statement: import Clayground.Physics

    Detailed Description

    PhysicsItem provides the foundation for all physics-enabled components, handling bidirectional coordinate synchronization between world units and screen pixels, and wrapping a Box2D Body.

    Example usage:

    import Clayground.Physics
    import Box2D
    
    PhysicsItem {
        xWu: 5; yWu: 10
        widthWu: 2; heightWu: 1
        pixelPerUnit: 50
        bodyType: Body.Dynamic
    }

    Properties

    Conversion factor between pixels and world units.

    X position in world units.

    Y position in world units.

    Width in world units.

    Height in world units.

    The Box2D body instance.

    Physics world reference. Auto-detected if physicsWorld exists in context.

    Linear motion damping coefficient.

    Angular motion damping coefficient.

    Body type: Body.Static, Body.Kinematic, or Body.Dynamic.

    Enable continuous collision detection for fast-moving objects.

    Whether the body can sleep when inactive.

    Prevent the body from rotating.

    Whether the body is active in the physics simulation.

    Whether the body is awake (not sleeping).

    Linear velocity vector (x, y).

    Angular velocity in radians per second.

    List of fixtures attached to this body.

    Gravity effect multiplier for this body.