Cocos2d-x Source Code read 1 UI tree 1 (the first system and the effectiveness of reading the source code sentiment), cocos2d-xui
I seldom looked at the source code before and thought it was boring and I had no clue. To tell the truth, there are few opinions, but to grow as a programmer, you must break through your own bottlenecks.
Maybe my talent is not writing code here. Maybe this is the harder it is to go, maybe it is a shortest pit with a gold mine. If I stick to it, I will dig it into the gold mine.
However, if you don't have so many options, try to be strong. Even if you are not good at it, even if you fall behind a lot, even if, even ,....
Http://cn.cocos2d-x.org/tutorial/show? Id = 2157
We recommend that you go here to watch this video. You may have no clue about the source code. The video effect following instructor Wang is still very good.
Here is my main function recorded based on the video. It involves adding, deleting, setting attributes, and searching nodes. You can view the video and read the source code in detail. It feels really good. (* ^__ ^ *)......
Watch the video by yourself.
Virtual void ignoreAnchorPointForPosition (bool newValue); can only be used for Scene and Layer. If it is set to true, (0, 0) is used as the anchor no matter how many anchors are set.
Virtual void setAnchorPoint (const Vec2 & anchorPoint)
Virtual const Vec2 & getAnchorPoint () const; returned position of the anchor (percentage)
Virtual const Vec2 & getAnchorPointInPoints () const; return the position of the anchor (Specific pixel value)
Virtual void setPosition (const Vec2 & position); sets the position of the user in the coordinate system of the parent UI. position is relative to the OpenGL coordinate system.
Virtual void setNormalizedPosition (const Vec2 & position); Use a value between 0 and 1 to set the position. The value between 0 and 1 is equivalent to pos/getParent ()-> getContentSize ();
Virtual const Mat4 & getNodeToParentTransform () const; returns a matrix that converts the coordinates of the sub-UI to the coordinates of the parent UI.
Virtual AffineTransform getNodeToParentAffineTransfrom () const; get an affination transformation. You can convert the coordinates of the sub-UI to the coordinates of the parent UI, which is smaller than the Mat4 matrix.
Virtual const Mat4 & getParentToNodeTransform () const; returns a matrix that converts the coordinate system of the parent UI to the coordinate system of the Child UI.
Virtual AffineTransform getParentToNodeAffineTransfrom () const; get an affine transformation, which can convert the coordinate system of the parent UI to the coordinate system of the Child UI
Virtual Mat4 getNodeToWorldTransfrom () const;
Virtual AffineTranfrom getNodeToWorldAffineTransfrom () const;
Virtual Mat4 getWorldToNodeTransfrom () const;
Virtual AffineTransfrom getWorldToNodeAffineTransfrom () const;
Vec2 convertToNodeSpace (const Vec2 & worldPoint) const;
Vec2 convertToWorldSpace (const Vec2 & nodePoint) const;
Vec2 convertToNodeSpaceAR (const Vec2 & worldPoint) const; is added to the coordinate system of the anchor. If the anchor is (0, 0), it is the same as convertToNodeSpace. Otherwise, the anchor prevails.
Vec2 convertToWorldSpaceAR (const Vec2 & nodePoint) const; is added to the coordinate system of the anchor. If the anchor is (0, 0), it is the same as convertToWorldSpace. Otherwise, the anchor prevails.
Vec2 convertTouchToNodeSpace (Touch * touch) const;
Vec2 convertTouchToNodeSpaceAR (Touch * touch) const;
Virtual void addChild (Node * child, int localZorder, int tag );
Virtual Node * getChildByTag (int tag) const;
Virtual Node * getChildByName (const std: string & name) const;
Virtual void setParent (Node * parent );
Virtual Node * getParent () {return _ parent ;}
Virtual void removeFromParent ();
Virtual void removeFromParentAndCleanup (bool cleanup );
Virtual void removeChild (Node * child, bool cleanup = true );
Virtual ssize_t getChildrenCount () const;
Virtual void removeAllChildren ();
Virtual void removeAllChildrenWithCleanup (bool cleanup );