我正在尝试将使用 Tiled 应用程序制作的简单 TMX Tiled Map 加载到 Visual Studio 中。但我收到此错误:
????????????
????????
'TaskHost.exe' (Win32): Loaded 'C:\Windows\System32\StorageProxy.dll'. Cannot find or open the PDB file.
'TaskHost.exe' (Win32): Loaded 'C:\Windows\System32\Windows.Phone.Storage.dll'. Cannot find or open the PDB file.
'TaskHost.exe' (Win32): Loaded 'C:\Windows\System32\PhotosAPI.dll'. Cannot find or open the PDB file.
'TaskHost.exe' (Win32): Loaded 'C:\Windows\System32\PhotosServiceClient.dll'. Cannot find or open the PDB file.
First-chance exception at 0x676D0BFB (libcocos2d_v3.3_WindowsPhone_8.0.dll) in TaskHost.exe: 0xC0000005: Access violation reading location 0x00000178.
Unhandled exception at 0x676D0BFB (libcocos2d_v3.3_WindowsPhone_8.0.dll) in TaskHost.exe: 0xC0000005: Access violation reading location 0x00000178.
The program '[4760] TaskHost.exe' has exited with code 0 (0x0).
因此,我进行了一些挖掘,发现这是一个错误,当您的资源与 TMX 文件不在同一目录中时,这是一个错误,最终根据此链接修复
http://discuss.cocos2d-x.org/t/cocos2d-x-v3-tilemap-image-source-path/8315
我在用Cocos 2d-x V3.3
这是我在 MainScene 的 init() 函数中使用的代码
bool MainScene::init()
{
if (!Layer::init())
{
return false;
}
...
auto tmxMap = TMXTiledMap::create("TMX/test-tiled-map.tmx");
this->addChild(tmxMap);
...
return true;
}
此外,我的磁贴资源与我的 .tmx 文件属于同一位置。即资产/资源/TMX/文件夹
这是我的 .tmx 文件:
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" renderorder="right-down" width="41" height="41" tilewidth="35" tileheight="35" nextobjectid="1">
<tileset firstgid="1" name="OriginMap" tilewidth="35" tileheight="35">
<tile id="0">
<image width="35" height="35" source="water.png"/>
</tile>
<tile id="1">
<image width="35" height="35" source="water-bot.png"/>
</tile>
<tile id="2">
<image width="35" height="35" source="water-bot-left.png"/>
</tile>
<tile id="3">
<image width="35" height="35" source="water-bot-right.png"/>
</tile>
<tile id="4">
<image width="35" height="35" source="water-left.png"/>
</tile>
<tile id="5">
<image width="35" height="35" source="water-right.png"/>
</tile>
<tile id="6">
<image width="35" height="35" source="water-top.png"/>
</tile>
<tile id="7">
<image width="35" height="35" source="water-top-left.png"/>
</tile>
<tile id="8">
<image width="35" height="35" source="water-top-right.png"/>
</tile>
</tileset>
<layer name="Tile Layer 1" width="41" height="41">
<data>
<tile gid="1"/>
<tile gid="1"/>
<tile gid="1"/>
<tile gid="1"/>
<tile gid="1"/>
... (lots of tiles of water) ...
<tile gid="1"/>
<tile gid="1"/>
</data>
</layer>
</map>
Visual Studio 生成的调用堆栈:
> libcocos2d_v3.3_WindowsPhone_8.0.dll!cocos2d::Node::addChild(cocos2d::Node * child=0x00000000) Line 1065 C++
EmpiresAtWarComponent.dll!MainScene::init() Line 94 C++
EmpiresAtWarComponent.dll!MainScene::create() Line 18 C++
EmpiresAtWarComponent.dll!MainScene::createScene() Line 9 C++
EmpiresAtWarComponent.dll!AppDelegate::applicationDidFinishLaunching() Line 41 C++
libcocos2d_v3.3_WindowsPhone_8.0.dll!cocos2d::Application::run() Line 77 C++
EmpiresAtWarComponent.dll!Cocos2dRenderer::[DirectXBase]::CreateGLResources() Line 63 C++
EmpiresAtWarComponent.dll!DirectXBase::UpdateDevice(ID3D11Device1 * device=0x005c7744, ID3D11DeviceContext1 * context=0x005c8820, ID3D11RenderTargetView * renderTargetView=0x03112a38) Line 110 C++
EmpiresAtWarComponent.dll!cocos2d::Direct3DInterop::Draw(ID3D11Device1 * device=0x005c7744, ID3D11DeviceContext1 * context=0x005c8820, ID3D11RenderTargetView * renderTargetView=0x03112a38) Line 159 C++
EmpiresAtWarComponent.dll!Direct3DContentProvider::Draw(ID3D11Device1 * device=0x005c7744, ID3D11DeviceContext1 * context=0x005c8820, ID3D11RenderTargetView * renderTargetView=0x03112a38) Line 64 C++