Here is my example.
let layer = map.layerAt(i);
if (layer.isObjectLayer) {
for (let i = 0; j < layer.objectCount; i++) {
let object = layer.objectAt(i);
}
}
Sadly, it’s wrong: TypeError: Property ‘objectAt’ of object Tiled::EditableTileLayer(0x5ab2523e9e80) is not a function
2 Likes
So, layer.objectAt
doesn’t work, but layer.objects
yes.
I don’t know why.
let layer = map.layerAt(i);
if (layer.isObjectLayer) {
for (const o of layer.objects) {
tiled.log(`obj: ${o.id}, ${o.text}`)
}
}
2 Likes
This says your layer is a Tile Layer. Did you actually have the layer.IsObjectLayer check in there when you ran the code?
1 Like
Oh, I re-run it, layer.objectAt
is ok now. Sorry for my mistake, maybe I’m forgot to save it before. Just ignore it.
let layer = map.layerAt(i);
if (layer.isObjectLayer) {
for (let i = 0; j < layer.objectCount; i++) {
let object = layer.objectAt(i);
}
}
Maybe I forget to save the code. Sorry. just ignore it
1 Like