cocos2dx3.x如何传私有数据??

llller llller 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
设置了几个私有数据
item_0->setUserObject(new RechargeEntity(0, 1));
item_1->setUserObject(new RechargeEntity(0, 2));
item_2->setUserObject(new RechargeEntity(0, 3));

在点击事件里取的时候,就变成 空 了...
if(item_0->getBoundingBox().containsPoint(touch->getLocation())){
RechargeEntity *re0 = (RechargeEntity*)item_0->getUserData();
}
if(item_1->getBoundingBox().containsPoint(touch->getLocation())){
RechargeEntity *re1 = (RechargeEntity*)item_1->getUserData();
}
if(item_2->getBoundingBox().containsPoint(touch->getLocation())){
RechargeEntity *re2 = (RechargeEntity*)item_2->getUserData();
}


为什么re1, re2取出来的都是null???
为什么re0取出来的是item_2的私有数据...

这是怎么回事???
...全文

相关推荐

评论
收藏 已收藏
分享
返回顶部
llller
Cocos2d-x 726 成员 671 内容