前端之家收集整理的这篇文章主要介绍了
Cocos2dx C++ --取得子节点在屏幕中相对位置,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
- Sprite*pTest1=Sprite::create("CloseNormal.png");
- pTest1->setPosition(ccp(100.0f,120.0f));
-
- Sprite*pTest2=Sprite::create("CloseNormal.png");
- pTest2->setPosition(ccp(10.0f,12.0f));
- pTest1->addChild(pTest2);
- this->addChild(pTest1);
- Vec2point=pTest2->getParent()->convertToWorldSpaceAR(pTest2->getPosition());
- CCLOG("pos1=%f,%f",pTest1->getPosition().x,pTest1->getPosition().y);
- CCLOG("pos2=%f,pTest2->getPosition().x,pTest2->getPosition().y);
- CCLOG("pos3=%f,point.x,point.y);
原文链接:https://www.f2er.com/cocos2dx/339081.html