设在node的父空间内有一点p,要求其转化到node局部空间后的坐标p_local,代码如下:
node->getNodeToParentTransform();//in order node->parentToNodeTransform() got right result, we must call node->getNodeToParentTransform() first, this is a bug of cocos2dx 3.3, see:
CCAffineTransform parentToNodeTransform=node->parentToNodeTransform();
p_local=CCPointApplyAffineTransform(p,parentToNodeTransform);
注意,不应该用 p_local=node->convertToNodeSpace(p),这是错的,因为看convertToNodeSpace的实现可知,它其实是convertFromWorldSpaceToNodeSpace,而不是convertFromFatherSpaceToNodeSpace。