TMX Tilemap访问冲突异常

时间:2015-01-30 15:51:19

标签: c++ windows-phone-8 cocos2d-x cocos2d-x-3.0 tmx

我正在尝试将使用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++

1 个答案:

答案 0 :(得分:0)

答案很简单......

导入资源时,必须设置

  

“如果更新则复制”作为资源的值在“复制到输出目录”部分下...执行该操作将文件复制到您的构建,否则它永远不会到达cocos。因此,“访问违规”......

http://www.cocos2d-x.org/news/78

根据VS 2014,此链接非常陈旧。它说

  

解决方案非常简单,即将资源文件Content field&gt;设置为“Yes”,将Item type字段设置为“不参与构建”。

对我来说并非如此。希望它可以帮助任何其他Cocos启动器解决问题! :)