0

When working with Phaser3, this worked:

map.createFromObjects('Layer_Objects', 'sprite', { key: 'item' })

'Layer_Objects' is the name of layer in Tiled. 'sprite' is the image name that will replace the itens created in the layer. 'item' is the name of points created with Tiled. I've tried many other options, but none of them worked, some of them asks for a GID, but Tiled is not generating this property. This project is being made with Phaser 2 CE, latest version.

1
  • 1
    Can you share the Phaser CE Code, that doesn't work? Or can you be a bit more specific what the problem is? Commented Oct 24, 2023 at 9:20

1 Answer 1

0

After some research, this code works:

this.map.createFromObjects('Layer_Objects', 'item', 'sprite', 0, true, false, this.itens);

Layer_Objects = name of layer objects created with Tiled

item = name of itens (points) created on Layer_Objects (they will be dynamically replaced for sprites in the code)

sprite = Name of spritesheet of sprite that will replace the itens created on layer by Tiled. It works even if the spritesheet has only 1 frame (index 0)

0 = Index of current frame from spritesheet.

true, false = Are default values (for existing sprite and created item will be on camera area), I didn't need to change those values

this.itens = The group of itens which those itens just created will belong

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.