LittleJS 1.31.0

Box2D

Box2dTileLayer

Box2d Tile Layer

  • adds Box2d support to tile layers
  • creates static box2d fixtures for solid tiles, call buildCollision to rebuild them after the tiles change
  • every cell with collision is a box solid from all sides, a one way tile (setOneWay) included

Extends Box2dStaticObject

Constructor

new Box2dTileLayer(tileLayer)box2d.js:1352

Create a Box2d tile layer object

tileLayer TileCollisionLayer

Tile layer for this object

Members

Methods

Inherited from Box2dObject

Inherited from EngineObject

Members

The tile layer

Methods

buildCollision(friction, restitution)box2d.js:1379

Create box2d collision fixtures for solid tiles

  • Called from a contact callback, a tile that breaks when hit, it is done once the step is done, as Box2D makes no fixtures inside its step
friction number optional, default 0.2
restitution number optional, default 0