0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-12-27 13:59:01 -05:00

fix issues with engine event.delta

This commit is contained in:
liabru 2020-03-11 23:47:07 +00:00
parent 8cfc234b5b
commit 6f5af774ce
3 changed files with 5 additions and 2 deletions

View file

@ -52,7 +52,7 @@ Example.compositeManipulation = function() {
Events.on(engine, 'afterUpdate', function(event) { Events.on(engine, 'afterUpdate', function(event) {
var time = engine.timing.timestamp, var time = engine.timing.timestamp,
timeScale = event.delta / 1000; timeScale = (event.delta || (1000 / 60)) / 1000;
Composite.translate(stack, { Composite.translate(stack, {
x: Math.sin(time * 0.001) * 10 * timeScale, x: Math.sin(time * 0.001) * 10 * timeScale,

View file

@ -64,7 +64,7 @@ Example.manipulation = function() {
scaleRate = 0.6; scaleRate = 0.6;
Events.on(engine, 'beforeUpdate', function(event) { Events.on(engine, 'beforeUpdate', function(event) {
var timeScale = event.delta / 1000; var timeScale = (event.delta || (1000 / 60)) / 1000;
if (scaleRate > 0) { if (scaleRate > 0) {
Body.scale(bodyF, 1 + (scaleRate * timeScale), 1 + (scaleRate * timeScale)); Body.scale(bodyF, 1 + (scaleRate * timeScale), 1 + (scaleRate * timeScale));

View file

@ -343,6 +343,7 @@ var Body = require('../body/Body');
* @event beforeUpdate * @event beforeUpdate
* @param {} event An event object * @param {} event An event object
* @param {number} event.timestamp The engine.timing.timestamp of the event * @param {number} event.timestamp The engine.timing.timestamp of the event
* @param {number} event.delta The delta time in milliseconds value used in the update
* @param {} event.source The source object of the event * @param {} event.source The source object of the event
* @param {} event.name The name of the event * @param {} event.name The name of the event
*/ */
@ -353,6 +354,7 @@ var Body = require('../body/Body');
* @event afterUpdate * @event afterUpdate
* @param {} event An event object * @param {} event An event object
* @param {number} event.timestamp The engine.timing.timestamp of the event * @param {number} event.timestamp The engine.timing.timestamp of the event
* @param {number} event.delta The delta time in milliseconds value used in the update
* @param {} event.source The source object of the event * @param {} event.source The source object of the event
* @param {} event.name The name of the event * @param {} event.name The name of the event
*/ */
@ -388,6 +390,7 @@ var Body = require('../body/Body');
* @param {} event An event object * @param {} event An event object
* @param {} event.pairs List of affected pairs * @param {} event.pairs List of affected pairs
* @param {number} event.timestamp The engine.timing.timestamp of the event * @param {number} event.timestamp The engine.timing.timestamp of the event
* @param {number} event.delta The delta time in milliseconds value used in the update
* @param {} event.source The source object of the event * @param {} event.source The source object of the event
* @param {} event.name The name of the event * @param {} event.name The name of the event
*/ */