slycrel / JSTileMap

TMX Map viewer for SpriteKit
Other
212 stars 34 forks source link

How to read Custom Properties from Object Layer #41

Open Bob997 opened 8 years ago

Bob997 commented 8 years ago

Hi,

I'm trying to access some custom properties under Object Layer. I tried to use something like: let dx = tmxObjectGroup.propertyNamed("DestinationPointX") print (dx) but I get a nil form dx.

here is a TMX snippet:

Thanks for any help.

riklowe commented 8 years ago

Hi - try this

    var objectsCount = 0
    var objectGroup = tileMap.groupNamed("Object Layer 1")

    for object in objectGroup.objects {

        objectsCount += 1
        print ("OBJECT :\(objectsCount)")

        print (object)

    }

Output OBJECT :1 { polygonPoints = "0,0 343,-44 343,3"; x = 331; y = 194; }