Cocos2dx--取得子节点在屏幕中的位置

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,position,坐标转换,子节点位置)