Jump to content

Load Object Layer from Tiled


tothniki
 Share

Recommended Posts

Helo,

i want to make a very simple bomberman game. 
I made some simple layers in tiled, and load them. Thats OK. I also made an object layer where i used only polylines / ellips to mark the bumper areas.
The problem is, that i cant load this object layer and i cant use.

I this moment  I use a  simple layer, so  the player can collide with all of the layers' objects, but i need to use polylines / ellips too.  So i realy need a solution.
Is there any way to solve this problem?  (I use ARCADE physics)

Thanks for the answers!

Link to comment
Share on other sites

There's no direct method in Arcade physics for doing anything with object layers from Tiled.

You do have access to it, though. The thing you get back from "game.add.tilemap" is the processed object that Tiled saves. There's an object in that map called "objects". Each of its properties corresponds to one object layer. If you had an object layer named "bumpers", your code would look something like this:

const map = this.game.add.tilemap('myMap');
if (map.objects.bumpers) {
  const bumpers = map.objects.bumpers;
  bumpers.forEach(bumper => {
    // do something here with the data
    console.log(bumper);
  });
}

 

Link to comment
Share on other sites

Quote

 

Thank you very much, now i understand how to use object layer. :) 
But how can i set collision all of the object layer's elements in the forEach? - I m searching it in phaser documents, but i cant find.

Thanks again!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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