natiny.backend.loop

Lua
natiny.backend.loop(callback)

Starts the main application loop. The callback is called once per frame.

Parameters

Name Type Description
callback function Function called every frame with delta time in seconds

Example

Lua
natiny.backend.loop(function(dt)
    update(dt)
end)

Notes

  • On desktop this runs a standard game loop.
  • On web this uses requestAnimationFrame.
  • The loop returns when the last window closes. With more than one open, closing one - by its close button or with natiny.window.destroy - leaves the others running, in whatever order they go. The same on every backend.
  • A window destroyed from inside the callback is released at the next frame boundary, so the frame that asked for it finishes first.