mirror of
https://github.com/geode-sdk/geode.git
synced 2025-02-17 00:30:26 -05:00
change CCNode::insertBefore behaviour to insert at the start if nullptr
This commit is contained in:
parent
295aedbdb5
commit
4613af6791
2 changed files with 5 additions and 2 deletions
|
@ -884,7 +884,7 @@ public:
|
|||
* @param child The node to add. The node may not be a child of another
|
||||
* node already
|
||||
* @param before The child the node is added before of. If this is null or
|
||||
* not a child of this node, the new child will be placed at the end of the
|
||||
* not a child of this node, the new child will be placed at the start of the
|
||||
* child list
|
||||
*/
|
||||
GEODE_DLL void insertBefore(CCNode* child, CCNode* before);
|
||||
|
|
|
@ -17,7 +17,10 @@ void CCNode::swapChildIndices(CCNode* first, CCNode* second) {
|
|||
|
||||
void CCNode::insertBefore(CCNode* child, CCNode* before) {
|
||||
this->addChild(child);
|
||||
if (m_pChildren->containsObject(before)) {
|
||||
if (
|
||||
(before && m_pChildren->containsObject(before)) ||
|
||||
(before = static_cast<CCNode*>(m_pChildren->firstObject()))
|
||||
) {
|
||||
child->setZOrder(before->getZOrder());
|
||||
child->setOrderOfArrival(before->getOrderOfArrival() - 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue