How to add all objects from tiles to their places?(

I think that there is a universal script, but I do not have enough understanding. If I use objGroup.create I can’t add the objects I want (by gid or id). createFromObjects adds all objects at once to their places, but does not display them, just black squares

    const objLayer = map.getObjectLayer('obj')['objects']
    const objGroup = this.add.group()
    objLayer.forEach((obj) => {
      // objGroup.create(obj.x, obj.y + offsetY, 'fence').setOrigin(0, 1)
      objGroup.create(obj.x, obj.y + offsetY, 'lamp').setOrigin(0, 1)
    })

or i try

    map.createFromObjects('obj', { gid: 326 })

In Phaser v3.55.2 you need to give a texture and frame:

map.createFromObjects('obj', { gid: 326, key: 'texture', frame: 0 })
1 Like

thank you very much, you helped me a lot. Sorry, but do you know how to add absolutely all sprites without writing map.createFromObjects(‘obj’, { gid: 339, key: ‘fence’, frame: 0 }) each time

If you loop through the objects you can read the id, gid, name, type, etc. and choose a texture and frame that way.

In Phaser v3.60 createFromObjects() will do this better.