0
\$\begingroup\$

I am trying to get the layers (or better, a special object layer) which contains a Vector2 location from a TiledMap, I know I could iterate over those, but I do not want to. How would I do that?

Thanks!

PS: I already asked at the MonoGame.Extended forums, but I may not get an answer there. That's why I'm asking here, too.

\$\endgroup\$
0
\$\begingroup\$

Have you tried the GetLayer method on the TiledMap?

Depending on your use case, you can get the object layer specifically by using either use the generic method:

var objectLayer = map.GetLayer<TiledMapObjectLayer>("layerName");

Or you can cast it you the object layer yourself:

var objectLayer = map.GetLayer("layerName") as TiledMapObjectLayer;

In either case it will return null if the layer doesn't exist or is of the wrong type.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .