What is the purpose of Phaser.Physics.Impact.CollisionMap#tiledef?

Recommended Posts

I'm using `setCollisionMapFromTilemapLayer` after calling `setCollisionByProperty` on my map layer. If I stick with the tile IDs generated by Tiled then the collision map thinks they're slope blocks based on default definitions for those IDs. If I change the ID to use the value of a custom property defined in Tiled then collision works as expected but the tiles don't render because their IDs don't match what the image assets are assigned to.. Why is there a static mapping of tile IDs to slope definitions?

Share this post

Link to post
Share on other sites

Have you checked out this example from v3 labs? It shows how to use Tiled + Impact together.

Impact's collision map doesn't really care about tiles - only different kinds of slopes. The collision map is just a 2D array filled with IDs that say which slope is at each grid location in the world. I attached a visualization of the default slope definitions, which corresponds to these defs in v3 code. CollisionMap#tiledef is set to those defs by default. 

setCollisionMapFromTilemapLayer reads the tiles in a layer and creates an appropriate CollisionMap from them. You have a couple options for specifying the mapping from Tile -> Slope ID. That labs examples walks through them.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.