0
0
Fork 0
mirror of https://github.com/liabru/matter-js.git synced 2024-12-02 10:49:45 -05:00
liabru-matter-js/examples/plugin.js
2016-08-03 01:04:45 +01:00

48 lines
1 KiB
JavaScript

(function() {
var Common = Matter.Common;
var MatterPlugin = {
name: 'matter-plugin',
version: '0.2.0',
for: 'matter-js@^0.10.0',
uses: [
'matter-plugin-2@^0.1.1',
'matter-plugin-3@^0.10.0'
],
options: {
thing: 1
},
install: function(base) {
base.Engine.create = Common.chain(
Matter.Engine.create,
MatterPlugin._engineCreate
);
base.Body.create = Common.chain(
MatterPlugin._bodyCreate,
Matter.Body.create
);
},
_engineCreate: function(element, options) {
var engine = this;
console.log('2nd patched engine create!', engine);
},
_bodyCreate: function(options) {
console.log('patched body create!', options);
}
};
Matter.Plugin.exports(MatterPlugin);
window.MatterPlugin = MatterPlugin;
})();