<Common methods of Node>
a. Set the Z-axis coordinate of the Node node
virtual void setZOrder(int localZOrder);
b. Set the scaling of the Node node
void setScale(float scale);
Note: The scaling of the graphics in the game will change the quality of the graphics. It is better to shrink than enlarge. (It is best to use PS to make multiple pictures of different sizes for the same picture in the game with different sizes)
Zoom can do dynamic pictures, zoom in or out. (There is an example in the game topic)
c. Set the anchor point of the Node node
setAnchorPoint(Vec2 point);
The anchor point defaults to (0.5,0.5); the position and rotation of the Node node are relative to the anchor point.
d. Get the size of the Node node
virtual const Size& getContentSize() const;
e. Set whether the Node node is visible
virtual void setVisible(bool visible);
f. Set the rotation of the Node node
virtual void setRotation(float rotation);
g. Add child nodes to the current node
virtual void addChild(Node * child);
h. Add a child node to the current node and set the index of the child node in the current node
virtual void addChild(Node * child, int tag);
i. Get the child nodes of the current node according to the index
inline T getChildByTag(int tag) const
j. Determine whether the current node is displayed
virtual bool isRunning() const;
k. Get the current node rectangle bounding box
virtual Rect getBoundingBox() const;
-------action:
a. Execute the action and return the executed action
virtual Action* runAction(Action* action);
b. Stop all actions and delete all actions from the current node's action list
void stopAllActions();
c. Stop the action and remove the action from the current node's action list
void stopAction(Action* action);
d. Stop the action based on the index in the action list and delete the action from the current node's action list
void stopActionByTag(int tag);
e. Get the action based on its index in the action list
Action* getActionByTag(int tag);
-------onEnter:
Note: When calling the following 4 functions, first call these 4 functions of the parent class to complete some standardization work.
a. onEnter():-----> The current node is created, but has not been displayed (create child nodes)
b. onEnterTransitionDidFinsh():-----> Called after the current node and child nodes are displayed (onEnter ends)
c. onExit():----> Called when the current node is removed from the screen (when the scene is switched)
d. onExitTransitionDidStart():----> before onExit()
Sequence relationship: When scene switching occurs:
onEnter()--->onEnterTransitionDidFinsh()---->onExitTransitionDidStart()---->onExit()--->The destructor of the current node
Question: Unable to enter onEnterTransitionDidFinsh() function? ? ? ?
-------REMOVES:
a. Completely delete the current node from the parent node and decrement the reference count by one
virtual void removeFromParent();
b. Delete the current node from the parent node, true: the reference count is decremented by one; false: the reference count is not decremented by one
virtual void removeFromParentAndCleanup(bool cleanup);
c. Delete the current node from the parent node clock, true: the reference count is decremented by one; false: the reference count is not decremented by one
virtual void removeChild(Node* child, bool cleanup = true);
d. Delete the current node from the parent node by index, true: the reference count is decremented by one; false: the reference count is not decremented by one
virtual void removeChildByTag(int tag, bool cleanup = true);
e. Delete the current node from the parent node by name, true: the reference count is decremented by one; false: the reference count is not decremented by one
virtual void removeChildByName(const std::string &name, bool cleanup = true);
f. Delete all child nodes in the current node (onExit() and destructor do not have to be called), and the reference count is decremented by one
virtual void removeAllChildren();
g. Delete all child nodes in the current node (onExit() and destructor do not have to be called),, true: the reference count is decremented by one; false: the reference count is not decremented by one
virtual void removeAllChildrenWithCleanup(bool cleanup);