Jump to content

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


jorbascrumps
 Share

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?

Link to comment
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.

slopes.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...