A coordinate wrapping plugin for matter.js
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.
See the demo.
Get the matter-wrap.js file directly or get it via npm:
npm install matter-wrap
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 = MatterBodies
Check out the examples.
See the API docs.