Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

How to add collision to Tiled Polyline?


Growler
 Share

Recommended Posts

Pretty straightforward question: I want to draw my collision layers in Tiled, preferrably using the Polyline tool.

 

I would use createFromObjects, but I don't really need the polyline to appear as a sprite, or appear at all (except for debug mode as a collision layer).

Phaser: 2.6.2

Physics: Arcade

 

Create() {

     ...

    map = game.add.tilemap('mario');
    map.addTilesetImage('tileset', 'tiles');
    layer = map.createLayer('Tile Layer 1');

    boundary = map.objects.boundaries[0];

    player = game.add.sprite(map.objects.mainPlayer[0].x, map.objects.mainPlayer[0].y, 'dude');
    game.physics.arcade.enable(player);
    player.body.collideWorldBounds = true;

     ...

 }

 

Update() {

    ...

    game.physics.arcade.collide(player, boundary);

    ...

 

Screen Shot 2018-01-31 at 10.31.09 PM.png

Screen Shot 2018-01-31 at 10.38.11 PM.png

Link to comment
Share on other sites

No ways to accomplish this other than box/sprite collision? MelonJS supports this out of the box and would expect Phaser to do so as well. I'm in the process of creating a quick demo to compare Phaser against other HTML5 game engines and need this to work.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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