Matter.TileBody.setFromTileCollision no longer checks if the shape is concave or convex before modifying the vertices, as the update to the Matter.js lib in 3.12 stopped this from working with Tiled collision shapes.

This commit is contained in:
Richard Davey 2019-01-08 11:50:21 +00:00
parent d9f0483437
commit 30dda882eb
3 changed files with 10 additions and 7 deletions

View file

@ -211,6 +211,7 @@ one set of bindings ever created, which makes things a lot cleaner.
* `WebGLRenderer.preRender` now calls `gl.clearColor` in order to restore the background clear color in case something, like a Render Texture, has changed it.
* `Map.set` will now update an existing value if you provide it with a key that already exists within the Map. Previously, if you tried to set the value of a key that existed it would be skipped.
* `MatterSprite` would set its `type` property to be `Image`. It now sets it to be `Sprite` as it should do.
* `Matter.TileBody.setFromTileCollision` no longer checks if the shape is concave or convex before modifying the vertices, as the update to the Matter.js lib in 3.12 stopped this from working with Tiled collision shapes.
### Bug Fixes

View file

@ -220,12 +220,14 @@ var MatterTileBody = new Class({
// matter expects points to be relative to the center of mass. This only applies to
// convex shapes. When a concave shape is decomposed, multiple parts are created and
// the individual parts are positioned relative to (ox, oy).
if (Vertices.isConvex(points))
{
var center = Vertices.centre(vertices);
ox += center.x;
oy += center.y;
}
//
// Update: 8th January 2019 - the latest version of Matter needs the Vertices adjusted,
// regardless if convex or concave.
var center = Vertices.centre(vertices);
ox += center.x;
oy += center.y;
body = Bodies.fromVertices(ox, oy, vertices, options);
}

View file

@ -537,7 +537,7 @@ var World = new Class({
convertTilemapLayer: function (tilemapLayer, options)
{
var layerData = tilemapLayer.layer;
var tiles = tilemapLayer.getTilesWithin(0, 0, layerData.width, layerData.height, {isColliding: true});
var tiles = tilemapLayer.getTilesWithin(0, 0, layerData.width, layerData.height, { isColliding: true });
this.convertTiles(tiles, options);