Swift parse problems


(Velin) #1

I’m new to swift and trying to create some tiled levels for a 2D side scroller game. I can’t find any info online about parsing through images. I found it for rectangular shapes, but anything else I try to look for is in ObjC or some other language. Anyone know of tutorials for tiled specifically for swift?


(Erik Schilling) #2

If I understand you correctly, you want to build a game for ios?
You might want to check out http://koboldkit.com/ then (Or in general https://github.com/bjorn/tiled/wiki/Support-for-TMX-maps). They seem to have some tutorials here too: http://wiki.koboldkit.com/display/KKD/Getting+Started.

Regards,
Ablu


#3

@Ablu The websites you gave are not in Swift. I have no idea how to parse the TMX files with Swift. Can you please give some websites that actually explain how to parse the files or just explain it.


(Velin) #4

@Ablu thanks for the reply. I researched koboldkit before posting here but it seems I have the same issue as @JJJPPP since they haven’t switched to swift yet :-/.


(Erik Schilling) #5

https://github.com/bjorn/tiled/wiki/TMX-Map-Format explains the map format. You can read it using your xml parser library of choice.

I unfortunatly have no experience with swift. So I fear I cannot help with this.

Regards,
Ablu

EDIT: Sorry. I posted the wrong link. Updated!


#6

Actually, I used JSTileMap to parse the TMX files and actually got it to work. @vhristov Here is the link I used to find how to do it: https://github.com/slycrel/JSTileMap and use http://stackoverflow.com/questions/25995131/how-to-use-jstilemap-in-swift to help you understand what to do.


(Velin) #7

thanks! this is definitely going to help. I have some parse code from tutorials I took, but having lots of issues with the correct Y coordinates translating over. Always need to adjust depending not he layer object.


#8

@vhristov You should something about being able to parse rectangular shapes in Swift. I am trying to set a spawn point in the map, and I don’t really know how to approach it. Do you know anything about this?


(Steffen Itterheim) #9

TilemapKit will take the burden of parsing TMX files from you. It works with Swift.

I plan on adding all the annoying bits as well, such as spawning nodes (or custom classes) for any given object, and using different nodes for a given tile GID so you could have tiles that will actually be particle emitters or using custom shaders at runtime.