Skip to content

Commit

Permalink
catch missing plugin require in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jan 31, 2021
1 parent 2ade78f commit 1ba1255
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 10 additions & 6 deletions examples/avalanche.js
@@ -1,12 +1,16 @@
var Example = Example || {};

Example.avalanche = function() {
if (typeof MatterWrap !== 'undefined') {
// either use by name from plugin registry (Browser global)
Matter.use('matter-wrap');
} else {
// or require and use the plugin directly (Node.js, Webpack etc.)
Matter.use(require('matter-wrap'));
try {
if (typeof MatterWrap !== 'undefined') {
// either use by name from plugin registry (Browser global)
Matter.use('matter-wrap');
} else {
// or require and use the plugin directly (Node.js, Webpack etc.)
Matter.use(require('matter-wrap'));
}
} catch (e) {
// could not require the plugin or install needed
}

var Engine = Matter.Engine,
Expand Down
16 changes: 10 additions & 6 deletions examples/ballPool.js
@@ -1,12 +1,16 @@
var Example = Example || {};

Example.ballPool = function() {
if (typeof MatterWrap !== 'undefined') {
// either use by name from plugin registry (Browser global)
Matter.use('matter-wrap');
} else {
// or require and use the plugin directly (Node.js, Webpack etc.)
Matter.use(require('matter-wrap'));
try {
if (typeof MatterWrap !== 'undefined') {
// either use by name from plugin registry (Browser global)
Matter.use('matter-wrap');
} else {
// or require and use the plugin directly (Node.js, Webpack etc.)
Matter.use(require('matter-wrap'));
}
} catch (e) {
// could not require the plugin or install needed
}

var Engine = Matter.Engine,
Expand Down

0 comments on commit 1ba1255

Please sign in to comment.