Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/samme/phaser-plugin-debug-arcade-physics

Draws properties of Arcade Physics bodies. Phaser 2/CE
https://github.com/samme/phaser-plugin-debug-arcade-physics

phaser phaser-arcade-physics phaser-plugin

Last synced: 3 months ago
JSON representation

Draws properties of Arcade Physics bodies. Phaser 2/CE

Awesome Lists containing this project

README

        

Draws properties of Arcade Physics bodies. [Demo](https://samme.github.io/phaser-plugin-debug-arcade-physics/)

![Screenshot](https://samme.github.io/phaser-plugin-debug-arcade-physics/screenshot.png)

Install
-------

npm install -S phaser-plugin-debug-arcade-physics

or

bower install -S samme/phaser-plugin-debug-arcade-physics

or add [DebugArcadePhysics.js](dist/DebugArcadePhysics.js) after phaser.js.

Use 🚀
---

```javascript
game.plugins.add(Phaser.Plugin.DebugArcadePhysics);
// OR
game.plugins.add(Phaser.Plugin.DebugArcadePhysics, {
// options … (see Configure, below)
});
```

### Configure

You can try these in the [demo](https://samme.github.io/phaser-plugin-debug-arcade-physics/).

```javascript
game.debug.arcade.configSet({ // default values:
bodyFilled: false,
filter: null ,
lineWidth: 1 ,
on: true ,
renderAcceleration: true ,
renderAngularAcceleration: true ,
renderAngularDrag: true ,
renderAngularVelocity: true ,
renderBlocked: true ,
renderBody: true ,
renderBodyDisabled: true ,
renderCenter: true ,
renderConfig: false,
renderDrag: true ,
renderFriction: true ,
renderLegend: true ,
renderMaxVelocity: true ,
renderOffset: true ,
renderRotation: true ,
renderSpeed: true ,
renderTouching: true ,
renderVelocity: true ,
}); // -> see console for values
```

### Filters

Some filters are included:
- `exists`
- `isAlive`
- `isBullet`
- `isNotBullet`
- `isNotParticle`
- `isNotSprite`
- `isParticle`
- `isSprite`

```javascript
// Example:
// Hide bodies of objects w/ exists=false (Phaser ignores these, but doesn't disable them)
game.debug.arcade.configSet({
filter: Phaser.Plugin.DebugArcadePhysics.exists
});

// Example:
// Keep automatic rendering 'on' but limit to Bullets
game.debug.arcade.configSet({
filter: Phaser.Plugin.DebugArcadePhysics.isBullet
});

// Example:
// Keep automatic rendering 'on' but limit to certain objects:
game.debug.arcade.configSet({
filter: function (obj) { return obj.name === "player" }
});
```

### Special uses

```javascript
// Turn automatic rendering off
game.debug.arcade.off()

// Draw just one body
game.debug.arcade.renderObj(player);

// Draw one property of one body
game.debug.arcade.renderVelocity(player);
```