我Tiled里面不添加圖塊,空的就能正常運行。
如果添加任意格式的圖塊圖片,然后再運行就會報記憶體錯誤。
是圖片素材還是路徑的原因。我全部都試了一下,還更換了Tiled的多個版本還是會出現問題。
拿記事本打開tmx檔案也沒發現問題。
地圖大小后面都試了1x1的,瓦片是32像素x32像素
png或jpg的圖片也是32x32像素。只要添加了一個圖塊他就報錯。
bool HelloWorld::init()
{
if (!Layer::init())
{
return false;
}
std::string file = "s.tmx";
auto str = String::createWithContentsOfFile(FileUtils::getInstance()->fullPathForFilename(file.c_str()).c_str());
_tileMap = TMXTiledMap::createWithXML(str->getCString(), "");
_background = _tileMap->layerNamed("Background");
addChild(_tileMap, -1);
return true;
}
uj5u.com熱心網友回復:
樓主解決了沒有。我也是轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/58835.html
標籤:Cocos2d-x
上一篇:【劍指金九銀十】程式員,如何做到不惑?(附四面拿到位元組跳動offer全程序)
下一篇:新人求問初入公司該如何快速上手
