Skip to content

API for interacting with MatterBodyTiles created from convertTilemapLayer #5473

Description

@ygongdev

I have not found a good way to access and customize MatterBodyTiles that are added into the matter world from convertTilemapLayer. Please let me know if there is an existing alternative.

An easy solution seems to just return the new array of MatterBodyTiles instead of the matter world itself. https://github.com/photonstorm/phaser/blob/v3.50.0/src/physics/matter-js/World.js#L975

A more robust solution might involve creating a tilemapLayer equivalent abstraction for matterBodyTiles?

This could be useful for customizing tilemaps in the matter world. For example, customizing each tile as a sensor to detect collisions, but not actually colliding with other objects.

Right now I do this to get all the matterTileBodies.

const { TileBody: MatterTileBody } = Phaser.Physics.Matter;

const matterTiles = tiles.map(tile => new MatterTileBody(this.matter.world, tile));

More than happy to help with a PR for the easy solution, if the idea is acceptable.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions