【问题标题】:TMX Tilemap Access Violation ExceptionTMX Tilemap 访问冲突异常
【发布时间】:2015-03-30 03:37:03
【问题描述】:

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

【问题讨论】:

  • 当您调试应用程序时,您应该会看到它崩溃的那一行。我们需要查看该行和调用堆栈。
  • 它会生成一个对话框等我把它放上来!
  • 日志中没有内容?像“找不到文件”或类似的东西?听起来返回的 TMXTiledMap 是 nil,这意味着如果日志中没有任何内容指示加载失败(以及如何解决它),您将不得不逐步执行代码并找出它无法创建的确切位置/原因TMX 地图节点。
  • 调试日志显示“无法找到或打开 PDB 文件”,但与 TMX 文件无关?
  • 您确定要调试应用程序吗?尝试在 init 中添加assert(false);,这应该让 VS 停止应用程序并显示该行。如果它只是崩溃或没有运行,那么您不是在调试,只是在运行(或调试发布版本)。

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


【解决方案1】:

答案很简单……

当你导入你的资源时,你必须设置

“如果较新则复制”作为“复制到输出目录”部分下的资源的值......这样做文件会被复制到您的构建中,否则它永远不会到达 cocos。因此,“访问冲突”...

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

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

解决方法很简单,就是将资源文件Content字段>设置为“是”,Item type字段设置为“不参与构建”。

对我来说不是这样。希望它可以帮助任何其他 Cocos 初学者解决这个问题! :)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-01
    • 2012-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多