0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2025-01-13 16:18:50 -05:00

added jsdoc for engine events

This commit is contained in:
liabru 2014-03-11 01:16:20 +00:00
parent eb5c6cdbf8
commit 730d688699

View file

@ -111,6 +111,15 @@ var Engine = {};
timestamp: timestamp
};
/**
* Fired at the start of a tick, before any updates to the engine or timing
*
* @event beforeTick
* @param {} event An event object
* @param {DOMHighResTimeStamp} event.timestamp The timestamp of the current tick
* @param {} event.source The source object of the event
* @param {} event.name The name of the event
*/
Events.trigger(engine, 'beforeTick', event);
delta = (timestamp - timing.timestamp) || _delta;
@ -140,6 +149,24 @@ var Engine = {};
frameCounter = 0;
}
/**
* Fired after engine timing updated, but just before engine state updated
*
* @event tick
* @param {} event An event object
* @param {DOMHighResTimeStamp} event.timestamp The timestamp of the current tick
* @param {} event.source The source object of the event
* @param {} event.name The name of the event
*/
/**
* Fired just before an update
*
* @event beforeUpdate
* @param {} event An event object
* @param {DOMHighResTimeStamp} event.timestamp The timestamp of the current tick
* @param {} event.source The source object of the event
* @param {} event.name The name of the event
*/
Events.trigger(engine, 'tick beforeUpdate', event);
// update
@ -147,30 +174,96 @@ var Engine = {};
var pairs = engine.pairs;
/**
* Fired after engine update, provides a list of all pairs that have started to collide in the current tick (if any)
*
* @event collisionStart
* @param {} event An event object
* @param {} event.pairs List of affected pairs
* @param {DOMHighResTimeStamp} event.timestamp The timestamp of the current tick
* @param {} event.source The source object of the event
* @param {} event.name The name of the event
*/
if (pairs.collisionStart.length > 0) {
Events.trigger(engine, 'collisionStart', {
pairs: pairs.collisionStart
});
}
/**
* Fired after engine update, provides a list of all pairs that are colliding in the current tick (if any)
*
* @event collisionActive
* @param {} event An event object
* @param {} event.pairs List of affected pairs
* @param {DOMHighResTimeStamp} event.timestamp The timestamp of the current tick
* @param {} event.source The source object of the event
* @param {} event.name The name of the event
*/
if (pairs.collisionActive.length > 0) {
Events.trigger(engine, 'collisionActive', {
pairs: pairs.collisionActive
});
}
/**
* Fired after engine update, provides a list of all pairs that have ended collision in the current tick (if any)
*
* @event collisionEnd
* @param {} event An event object
* @param {} event.pairs List of affected pairs
* @param {DOMHighResTimeStamp} event.timestamp The timestamp of the current tick
* @param {} event.source The source object of the event
* @param {} event.name The name of the event
*/
if (pairs.collisionEnd.length > 0) {
Events.trigger(engine, 'collisionEnd', {
pairs: pairs.collisionEnd
});
}
/**
* Fired after engine update and all collision events
*
* @event afterUpdate
* @param {} event An event object
* @param {DOMHighResTimeStamp} event.timestamp The timestamp of the current tick
* @param {} event.source The source object of the event
* @param {} event.name The name of the event
*/
/**
* Fired just before rendering
*
* @event beforeRender
* @param {} event An event object
* @param {DOMHighResTimeStamp} event.timestamp The timestamp of the current tick
* @param {} event.source The source object of the event
* @param {} event.name The name of the event
*/
Events.trigger(engine, 'afterUpdate beforeRender', event);
// render
if (engine.render.options.enabled)
engine.render.controller.world(engine);
/**
* Fired after rendering
*
* @event afterRender
* @param {} event An event object
* @param {DOMHighResTimeStamp} event.timestamp The timestamp of the current tick
* @param {} event.source The source object of the event
* @param {} event.name The name of the event
*/
/**
* Fired after engine update and after rendering
*
* @event afterTick
* @param {} event An event object
* @param {DOMHighResTimeStamp} event.timestamp The timestamp of the current tick
* @param {} event.source The source object of the event
* @param {} event.name The name of the event
*/
Events.trigger(engine, 'afterTick afterRender', event);
})();
};