Jump to content

multi layer json collide


Heppell08
 Share

Recommended Posts

Yeah the topic pretty much explains. My issue is I'm making a topdown map for testing at the minute but for some reason, I can't get the 2nd layer to collide.

I can get the first main layer to collide but can't collide the 2nd. What I'm after is the main bottom layer to have no collisions at all and have the 2nd layer be the collide layer.

Now I've switched the layers but that removes the 2nd layer under the main layer etc.

When I debug I get no bounds on the second layer. They both are in the same json file.

I tried var layer2 and created the map with everything visible as should be but just doesn't collide. I've also given the update the arcade collide for player and layer.

Any ideas?

Link to comment
Share on other sites

Does layer2 has a physical body?

That's what I've done:
 

[..]create: function() {  [..]  game.physics.arcade.enable(this.player);  [..]  this.layer1 = this.map.createLayer('background'); //no collision here  this.layer2 = this.map.createLayer('obstacles'); //collides  this.layer1.resizeWorld();  this.layer2.resizeWorld();  game.physics.arcade.enable(this.layer2);  this.map.setCollisionByExclusion([],true,this.layer2); //collides on every tile  [..]  },update: function() {  game.physics.arcade.collide(this.player, this.layer2);  [..]}, [..]

And it works: http://tannhauser-gate.net/projects/games/tilemap-test/ (currently here it is layer3, 'cause, layer2 collides different, see: http://tannhauser-gate.net/projects/games/tilemap-test/js/test.js)

Link to comment
Share on other sites

Hmmm, I didn't set any physical body property to my 2nd layer. I'll check your code against mine soon and see but looks like you're doing the same as me. Thanks!

 

Does collision not always require a physical body? Thought so, as it's not known to ARCADE otherwise. Just let me know your feedback, I owe you one. :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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