Matter.Runner module is an optional utility which provides a game loop,
that handles continuously updating a
Matter.Engine for you within a browser.
It is intended for development and debugging purposes, but may also be suitable for simple games.
If you are using your own game loop instead, then you do not need the
Instead just call
Engine.update(engine, delta) in your own loop.
See the included usage examples.
Creates a new Runner. The options parameter is an object that specifies any properties you wish to override the defaults.
Continuously ticks a
Matter.Engine by calling
Runner.tick on the
Ends execution of
Runner.run on the given
runner, by canceling the animation frame request event loop.
If you wish to only temporarily pause the engine, see
A game loop utility that updates the engine and renderer by one step (a 'tick').
Features delta smoothing, time correction and fixed or dynamic timing.
Engine.update(engine, delta) if you're using your own loop.
Properties / Options
The following properties are specified for objects created by
Matter.Runner.create and may be passed to it as
Number that specifies the time step between updates in milliseconds.
engine.timing.isFixed is set to
delta is fixed.
If it is
delta can dynamically change to maintain the correct apparent simulation speed.
1000 / 60
A flag that specifies whether the runner is running or not.
Boolean that specifies if the runner should use a fixed timestep (otherwise it is variable).
If timing is fixed, then the apparent simulation speed will change depending on the frame rate (but behaviour will be deterministic).
If the timing is variable, then the apparent simulation speed will be constant (approximately, but at the cost of determininism).
The following events are emitted by objects created by
Matter.Runner.create and received by objects that have subscribed using
Fired at the end of a tick, after engine update and after rendering
Fired after update
Fired at the start of a tick, before any updates to the engine or timing
Fired before update
Fired after engine timing updated, but just before update