Jump to content

Identifying Tiled objects


mariogarranz
 Share

Recommended Posts

I know Phaser includes a function to load sprites from tiled objects. However, because I want to be able to create not only sprites, but different kind of Objects (say different kind of enemies for a map), I'm creating my own function to iterate through the object list and create them.

 

For this, I need to identify different kind of objects, and I have 2 options:

1 - The "gid" value, automatically assigned by Tiled.

2 - A custom value such as "name" "type" or whatever, Tiled allows you to create.

 

 

The gid value is automatically assigned by Tiled, but I can't seem to find the logic behind this number. For example, I'm creating some objects and they all get the "gid" value of 157, but this seems to be an internal value of the application, and I would need to identify them. If I create another map, the value may change.

 

Adding names or types sounds more logical, say I could add "slime" "zombie" and "skeleton" types for different enemies. The problem is every time I add an object, I need to manually set this value inside Tiled, even if I already picked the corresponding image, there seems to be no way to save a preset for them.

I know this may be more of a Tiled question, so if mods consider this is the wrong place, I'm sorry and feel free to move it, but because I think this is an issue that other people may have had while working with Phaser I'm opening it in this subforum.

Thanks in advance for you help :)

Link to comment
Share on other sites

Hi,

sounds like you use the object properties in the map instead of tileproperties in the tileset.

set a class value or/and a custom hitbox in there.

use a tile for every type of enemy/object so you can have icons or a little preview image in Tiled.

loop through map.tilesets[0].tileProperties and save the gid and the tileproperties so you can create them via map.createFromObjects with the custom/tile class

Link to comment
Share on other sites

Hi,

sounds like you use the object properties in the map instead of tileproperties in the tileset.

set a class value or/and a custom hitbox in there.

use a tile for every type of enemy/object so you can have icons or a little preview image in Tiled.

loop through map.tilesets[0].tileProperties and save the gid and the tileproperties so you can create them via map.createFromObjects with the custom/tile class

 

Thanks a lot pxam.

That's not exactly what I want, because I'd prefer using image objects instead of tiles, so they look more like the ingame version, but it will do the trick pretty well :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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