Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/box2d-events
Easier event listening for Box2D collisions
https://github.com/hughsk/box2d-events
Last synced: 8 days ago
JSON representation
Easier event listening for Box2D collisions
- Host: GitHub
- URL: https://github.com/hughsk/box2d-events
- Owner: hughsk
- Created: 2013-08-09T06:54:25.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-08-09T11:20:32.000Z (over 11 years ago)
- Last Synced: 2024-10-17T16:39:46.526Z (22 days ago)
- Language: JavaScript
- Size: 109 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# box2d-events #
Box2D's collision event listeners only work (more or less) globally: you
create a listener and attach it to the world, which will get called every time
there's a collision.To make things a little more managable, here's a module which can take a
[box2dweb-commonjs](http://ghub.io/box2dweb-commonjs) world and give you
an `EventEmitter` in return. You can also listen to individual fixtures
for ease of use.## Installation ##
``` bash
npm install box2d-events
```## Usage ##
### `events = require('box2d-events')(Box2D, world)` ###
Returns an `EventEmitter` which will emit the following events:
* `begin(fixtureA, fixtureB, info)` when a collision first occurs between
two objects.
* `end(fixtureA, fixtureB, info)` when a collision stops occurring between two
objects.### `events.fixture(fixture)` ###
Returns an `EventEmitter` which will emit the same events as above, except only
when they involve that specific object. Note that the first fixture will
always be the one *not* belonging to the listener.