- 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);
- Vec2 point = pTest2->getParent()->convertToWorldSpaceAR(pTest2->getPosition());
- CCLOG("pos1 = %f, %f", pTest1->getPosition().x, pTest1->getPosition().y);
- CCLOG("pos2 = %f, %f", pTest2->getPosition().x, pTest2->getPosition().y);
- CCLOG("pos3 = %f, %f", point.x, point.y);
Cocos2dx C++ --取得子节点在屏幕中相对位置
最新推荐文章于 2022-08-24 17:53:48 发布