a coordinate wrapping plugin for matter-js
Switch branches/tags
Nothing to show
Clone or download
Latest commit 43be263 Jul 5, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build release 0.2.0 Jul 4, 2017
docs release 0.2.0 Jul 4, 2017
test initial commit of matter-wrap Feb 12, 2017
.babelrc initial commit Feb 12, 2017
.eslintrc initial commit Feb 12, 2017
.gitignore initial commit Feb 12, 2017
.npmignore initial commit of matter-wrap Feb 12, 2017
.travis.yml initial commit Feb 12, 2017
API.md release 0.2.0 Jul 4, 2017
LICENSE added license Feb 12, 2017
README.md implemented composite.plugin.wrap Jul 4, 2017
index.js implemented composite.plugin.wrap Jul 4, 2017
package.json release 0.2.0 Jul 4, 2017
webpack.config.js fix webpack config May 15, 2017
yarn.lock upgraded matter-tools Jul 4, 2017

README.md

matter-wrap

A coordinate wrapping plugin for matter.js

Build Status

This plugin allows you to automatically wrap the position of bodies and composites such that they always stay within the given bounds. Upon crossing a boundary the body will appear on the opposite side of the bounds, while maintaining its velocity. An example of this effect can be seen in the classic Asteroids and Pacman games.

Demo

See the demo.

matter-wrap

Install

Get the matter-wrap.js file directly or get it via npm:

npm install matter-wrap

Dependencies

Usage

Matter.use('matter-wrap');
// or
Matter.use(MatterWrap);

See Using Plugins for more information.

An example of a body that wraps between the bounds (0, 0) and (1024, 1024). For wrapping composites set composite.plugin.wrap as below.

var body = Matter.Bodies.circle(0, 0, 10, {
  plugin: {
    wrap: {
      min: {
        x: 0,
        y: 0
      },
      max: {
        x: 1024,
        y: 1024
      }
    }
  }
);

Examples

Check out the examples.

Documentation

See the API docs.