Jump to content

Loading "tile collision editor" defined tile's polygons P2


Recommended Posts



I loaded my tiles with game.physics.p2.convertTilemap() and it works. However, each tile is a square block and my "player" is floating on slanted tiles (similer to problem mentioned in here).


Using Tiled editor's "Tile Collision Editor", i defined the polygon I want but Phaser does not seem to pick it up.


Part of the exported JSON looks like this (tells me that the polyline was created):

 "tilesets":[        {         "firstgid":1,         "image":"tiles.png",         "imageheight":374,         "imagewidth":374,         "margin":0,         "name":"tiles",         "properties":            {            },         "spacing":2,         "tileheight":32,         "tiles":            {             "57":                {                 "objectgroup":                    {                     "draworder":"index",                     "height":0,                     "name":"",                     "objects":[                            {                             "height":0,                             "name":"",                             "polyline":[                                    {                                     "x":0,                                     "y":0                                    },                                     {                                     "x":32,                                     "y":-32                                    }],                             "properties":                                {                                },                             "rotation":0,                             "type":"",                             "visible":true,                             "width":0,                             "x":0,                             "y":32                            }],                     "opacity":1,                     "type":"objectgroup",                     "visible":true,                     "width":0,                     "x":0,                     "y":0                    }                }            },         "tilewidth":32        },         {         "firstgid":122,         "image":"items.png",         "imageheight":270,         "imagewidth":270,         "margin":0,         "name":"items",         "properties":            {            },         "spacing":2,         "tileheight":32,         "tilewidth":32        },         {         "firstgid":186,         "image":"sprites.png",         "imageheight":100,         "imagewidth":238,         "margin":0,         "name":"sprites",         "properties":            {            },         "spacing":2,         "tileheight":32,         "tilewidth":32        }]

How do I load the tile's collision polyline/polygon in Phaser when loading the tiled layer?



Link to comment
Share on other sites

  • 2 years later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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