当插入到CCDictionary中时,将标签添加到扩展CCNode的Cocos2d-x将消失
Cocos2d-x adding tag to extended CCNode disappear when insert in to CCDictionary
我尝试设置标记,它成功了,但当我将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++扩展强制多个python进程共享同一内存
- static_assert在宏中,但也可以扩展到可以用作函数参数的东西
- 如何将这个C++哈希表转换为动态扩展和收缩,而不是使用硬设置的最大值
- 扩展光电二极管探测器以支持多个传感器
- C++中的VLA,扩展名为std=C++11
- OpenGL 和 GLM 矩阵无法正确扩展,总是按比例缩小
- 基于范围的 for 循环:迭代使用一个元素扩展的向量
- C++返回 Numpy 数组的 Python 扩展模块
- 扩展可变参数模板中的变量名称
- 扩展C++生成的代码的模板参数类型名称
- 我想通过带有C++和Python的插件创建一个可扩展的应用程序
- VSCode IntelliSense无法识别SDL框架的SDL_image扩展库
- 将元组类型扩展为可变参数模板?
- 如何按文件扩展名引用文件夹中的文件
- HDF5Cpp 扩展复合数据集超板问题
- MSVC中的宏观扩展问题
- 嵌套参数包扩展失败
- C4204:使用的非标准扩展:非常量聚合初始值设定项
- [temp.variadic]中关于包扩展实例化的措辞
- 当插入到CCDictionary中时,将标签添加到扩展CCNode的Cocos2d-x将消失