我为spritekit游戏架起了JS TileMap。我在项目中放入了tmx文件,并尝试初始化JSTileMap对象
let map = JSTileMap(fileNamed: "level 1-1.tmx")
我得到这个错误
2014-11-15 17:43:03.428 MyGame [5726:1901295] *由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'*-[NSKeyedUnarchiver initForReadingWithData:]:不可理解的存档(0x3c,0x3f,0x78、0x6d,0x6c ,0x20、0x76、0x65)'
***首先抛出调用堆栈:
(
可能是找不到文件吗?我注意到如果我将文件名更改为不存在的文件,则会遇到相同的错误。
这是我的tmx文件的内容
<?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>
我尝试将其编辑为正好,仍然会抛出该错误。我确保包含libz.dylib
我究竟做错了什么?
最佳答案
我使用了错误的初始化方法
它应该是
let map = JSTileMap(named: "level 1-1.tmx")