← Back to Docs
  • index.html
  • Clayground
  • Clayground.Physics
  • PhysicsTimer
  • Clayground 2026.8
  • PhysicsTimer QML Type

    A timer that counts simulated time, one physics step at a time. More...

    Import Statement: import Clayground.Physics

    Detailed Description

    PhysicsTimer has the interface of a QML Timer, but its clock is the physics world: after every step it adds the step's time to elapsed and fires once that reaches interval. A pause fires nothing, single-stepping fires after as many steps as the interval takes, a hit stop or a lower time scale slows it exactly as much as the simulation.

    Example usage:

    import Clayground.Physics
    
    PhysicsTimer {
        world: theWorld.physics
        interval: 800
        repeat: true
        running: true
        onTriggered: enemy.decide()
    }

    Properties

    The Box2D world whose steps drive the timer. Inside a ClayWorld2d this is its physics property.

    Simulated milliseconds between start and trigger (default 1000).

    Whether the timer counts steps.

    Whether the timer fires again after each interval, carrying over the time a step overshot it.

    Whether starting the timer fires it right away as well.

    Simulated milliseconds since the timer started or last fired.

    Signals

    Emitted when interval simulated milliseconds have passed.

    Methods

    Starts the timer.

    Stops the timer.

    Starts the timer over from zero, running or not.