JS TileMap iOS 8 and swift, incomprehensible archive?

336 views Asked by At

I've bridged JS TileMap for my spritekit game. I've put a tmx file in my project and I'm trying to init a JSTileMap object

let map = JSTileMap(fileNamed: "level 1-1.tmx")

i get this error

2014-11-15 17:43:03.428 MyGame[5726:1901295] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0x3c, 0x3f, 0x78, 0x6d, 0x6c, 0x20, 0x76, 0x65)' *** First throw call stack: (

Could it be that it's not finding the file? I noticed if i change the filename to something nonexistent i get the same error..

Here is the contents of my tmx file

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="1000" height="800" tilewidth="1" tileheight="1">
 <tileset firstgid="1" name="enemies" tilewidth="80" tileheight="75">
  <tile id="0">
   <properties>
    <property name="name" value="EnemyA"/>
   </properties>
   <image width="66" height="75" source="../Atlases/iPhone/enemyA.atlas/[email protected]"/>
  </tile>
  <tile id="1">
   <image width="65" height="67" source="../Atlases/iPhone/enemyB.atlas/[email protected]"/>
  </tile>
  <tile id="2">
   <properties>
    <property name="name" value="EnemyC"/>
   </properties>
   <image width="60" height="60" source="../Atlases/iPhone/enemyC.atlas/[email protected]"/>
  </tile>
  <tile id="3">
   <image width="61" height="65" source="../Atlases/iPhone/enemyD.atlas/[email protected]"/>
  </tile>
  <tile id="4">
   <image width="74" height="58" source="../Atlases/iPhone/enemyE.atlas/[email protected]"/>
  </tile>
  <tile id="5">
   <properties>
    <property name="name" value="EnemyF"/>
   </properties>
   <image width="80" height="73" source="../Atlases/iPhone/enemyF.atlas/[email protected]"/>
  </tile>
 </tileset>
 <objectgroup color="#000000" name="Object Layer 1">
  <object name="EnemyA" type="enemy" gid="1" x="137" y="489"/>
  <object name="EnemyC" type="enemy" gid="6" x="468" y="454"/>
  <object name="EnemyB" type="enemy" gid="3" x="310" y="321"/>
 </objectgroup>
</map>

i've tried editing it down to just and it still throws that error. I'm making sure to include libz.dylib

what am i doing wrong?

2

There are 2 answers

0
hamobi On BEST ANSWER

I was using the wrong init method

it should be

let map = JSTileMap(named: "level 1-1.tmx")
0
Fael On

Try to remove @2 from your image files source.. Then run it again. I think you cannot use @2 in tiled. Also remove spaces from you tmx name.