我尝试设置标签并且成功完成,但是当我将CCnode插入CCDictionary时
并尝试获取CCNode并检查标记0。

int tagNum = 242;
    //Gem is class Gem :public CCNode , public CCTargetedTouchDelegate
    Gem *thisGem = new Gem();
    thisGem->retain();
    thisGem->setTag(tagNum);
    thisGem->initWithGame(this,zorder);
    int t1 = thisGem->getTag();
    // t1 = 242
    //set in container
    std::string gemID = thisGem->getGemId();
    gemsDictionary->setObject(thisGem,gemID); //gemsDictionary init in the contracture
    Gem *nextGemTest = (Gem *)gemsDictionary->objectForKey(gemID);
    int t2 = nextGemTest->getTag();
    // t2 is 0 ???

最佳答案

您可以尝试使用std::map<std::string, Gem *>代替CCDictionary

关于c++ - 当插入CCDictionary时,将Cocos2d-x添加到扩展CCNode的标签消失了,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17963218/

10-12 03:21