0

I am having trouble passing the objects from my tile map using the app Tiled to my app on XCode. How should I loop / create a method to do that?

I have tried this but it seems that it doesn't work:

if let ice = group.objectsNamed("IceObject") as? [[String:AnyObject]]
    {
        for iceObj in ice {
        let x = iceObj["x"] as? NSNumber
        let y = iceObj["y"] as? NSNumber

        iceSprite = SKSpriteNode(imageNamed: "ice.png")
        iceSprite.position = CGPoint(x: CGFloat(x!), y: CGFloat(y!))
        addChild(iceSprite)
        }
    }

group is initialized as a TMXObjectGroup

sangony
  • 11,636
  • 4
  • 39
  • 55
toom4ny
  • 63
  • 5
  • Pass objects from one app to another? What does that even mean? – matt May 22 '15 at 17:42
  • This might help. http://stackoverflow.com/questions/25995131/how-to-use-jstilemap-in-swift – sangony May 22 '15 at 17:45
  • I might not have been clear in my description sorry. What I mean is that I have added ObjectLayer called `IceObject` in the app `Tiled` and I have loaded that tile map to my XCode app. I want the x and y position of the IceObject and create it as a sprite node in XCode. I attempted that as shown above but without success unfortunately. – toom4ny May 22 '15 at 17:46
  • Thanks alot again sangony! I will try that it seems that the person posting it has already done it but I will have to understand the code which doesn't seem too complex. I will come back here again to tell whether i succeeded or still have problems :) – toom4ny May 22 '15 at 17:54
  • Okay that guy is a genius. It actually worked out for me. I just have to find the ID's of my tiles (which is easily done in the app `Tiled` and I think I understood most parts of the code - which will be the most important thing as I am preparing myself for the exam. I can ask my teacher or probably here, if I face some issues. Again, thanks alot! – toom4ny May 22 '15 at 18:07

0 Answers0