Class: JRunner

physics.JRunner(engine, render, renderCallbackopt, optionsopt)

Handles the link between the `PIXI` ticker and `Matter.js` time.
- Handles the `matter.js` engine time update

Constructor

new JRunner(engine, render, renderCallbackopt, optionsopt)

Parameters:
Name Type Attributes Default Description
engine Matter.Engine `Matter.js` engine instance.
render physics.JRender `JRender` class instance.
renderCallback physics.JRunner.onRender <optional>
null Function to be called every render, immediately after the `render.drawRender()` is called.
options physics.JRunner.Options <optional>
null Configuration object.
Source:
Example
const {..., physics} = require(`storymode`);
// Create jrender instance:
this.jrender = new physics.JRender({ptsPerMeterFactor:0.5});
this.jrunner = new physics.JRunner(this.engine, this.jrender, this.onRender.bind(this), {fixedTimestep: false});

Members

(readonly) renders :Array

A list of `JRender` instances managed by the runner.
Type:
  • Array
Source:

Methods

dispose()

Clean up method, must be called manually.
Source:

pauseTick()

Pauses the ticker.
Source:
Example
onDidExit(fromModal){
 super.onDidExit(fromModal);
 this.jrunner.pauseTick();
}

resumeTick()

Resumes the ticker.
Source:
Example
onWillArrive(fromModal){
 super.onWillArrive(fromModal);
 this.jrunner.resumeTick();
}

tickFixed()

Internal fixed timestep tick function.
- If the frame rate slows below the target rate, more engine updates are called to compensate before calling the render.
- See https://gafferongames.com/post/fix_your_timestep/
Source:

tickVariable()

Internal variable timestep tick function.
Source:

Type Definitions

onRender(elapsedMS)

Called after every `Matter.js` render.
Parameters:
Name Type Description
elapsedMS number Time elapsed in milliseconds from last frame to this frame.
Source:

Options

JRunner config options.
Type:
  • Object
Properties:
Name Type Attributes Default Description
fixedTimestep boolean <optional>
true 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).
Source: