0

我尝试设置标签并且它成功但是当我将 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 ???
4

1 回答 1

1

您可以尝试使用std::map<std::string, Gem *>而不是CCDictionary

于 2013-07-31T09:58:56.507 回答