diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 638c9dba2b..2ef7d66d36 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -86,6 +86,7 @@ CCNode::CCNode(void) , m_uOrderOfArrival(0) , m_eGLServerState(ccGLServerState(0)) , m_bReorderChildDirty(false) +, m_sOtherTransform(CCAffineTransformMakeIdentity()) { // set default scheduler and actionManager CCDirector *director = CCDirector::sharedDirector(); @@ -1158,13 +1159,17 @@ CCAffineTransform CCNode::nodeToParentTransform(void) m_sTransform = CCAffineTransformTranslate(m_sTransform, -m_obAnchorPointInPoints.x, -m_obAnchorPointInPoints.y); } } - + m_sTransform = CCAffineTransformConcat(m_sTransform, m_sOtherTransform); m_bTransformDirty = false; } return m_sTransform; } - +void CCNode::translateFormOtherNode(CCAffineTransform &transform) +{ + m_sOtherTransform = CCAffineTransformMake(transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty); + m_bTransformDirty = true; +} CCAffineTransform CCNode::parentToNodeTransform(void) { if ( m_bInverseDirty ) { diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index daa85b7aa4..83ad2d46a8 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -1256,6 +1256,10 @@ public: */ CCPoint convertTouchToNodeSpaceAR(CCTouch * touch); + /** + * Additional a transformation matrix, Used in is not parent-child relationship but we still need to maintain transformation parent-child + */ + void translateFormOtherNode(CCAffineTransform &transform); /// @} end of Coordinate Converters private: @@ -1290,6 +1294,7 @@ protected: CCSize m_obContentSize; ///< untransformed size of the node + CCAffineTransform m_sOtherTransform;///< transform CCAffineTransform m_sTransform; ///< transform CCAffineTransform m_sInverse; ///< transform