cocos creator 学习(五)

来源:互联网 发布:qq炫舞卡八音软件 编辑:程序博客网 时间:2024/06/05 19:45

Assert failed:TMX atlas index not found. Shall not happen


这个错误提示是让我去CCTMXLayer.cpp的第487行看这个函数:


ssize_t TMXLayer::atlasIndexForExistantZ(int z)
{
    int key=z;
    int *item = (int*)bsearch((void*)&key, (void*)&_atlasIndexArray->arr[0], _atlasIndexArray->num, sizeof(void*), compareInts);

    CCASSERT(item, "TMX atlas index not found. Shall not happen");

    ssize_t index = ((size_t)item - (size_t)_atlasIndexArray->arr) / sizeof(void*);
    return index;
}


当然我什么也没看懂,网上搜也没有。最为气愤的是浏览器上明明可以找得到索引。但是如果用模拟器跑就会报这个错。

layer.removeTileAt(p);
一开始我的p(也就是cc.p(18.3,9.2));

后来用Math.floor()向下取整

也就是现在的p(也就是cc.p(18,9));

这下就没有毛病了。