Why i can't set sprite hierarchy when using SpriteBatchNode?

Hey i try to set sprite hierarchy to parent root , taking the example from SpriteTest.cpp
from SpriteSkewNegativeScaleChildren example.
but in my code i allso add the sprites to SpriteBatchNode .
like this :


 auto cache = SpriteFrameCache::getInstance();
    cache->addSpriteFramesWithFile("leds/sprites.plist", "leds/sprites.png");   
    auto batch = SpriteBatchNode::create("leds/sprites.png");
    Sprite* Sprite_all_side_connector = Sprite::createWithSpriteFrameName("all_side_connector.png");
    batch->addChild(Sprite_all_side_connector);
    Sprite* Sprite_one_side_connector = Sprite::createWithSpriteFrameName("one_side_connector.png");
    batch->addChild(Sprite_one_side_connector);
    Sprite* Sprite_purple_stick = Sprite::createWithSpriteFrameName("purple_stick.png");
    batch->addChild(Sprite_purple_stick);
    Sprite* Sprite_red_stick = Sprite::createWithSpriteFrameName("red_stick.png");
    batch->addChild(Sprite_red_stick);
    Sprite* Sprite_yellow_ball = Sprite::createWithSpriteFrameName("yellow_ball.png");
    batch->addChild(Sprite_yellow_ball);
   
     addChild(batch, 0, TAGS::SPRITEBATCHNODE);        
    Sprite_all_side_connector->setPosition(ccp(winSize.width/2,winSize.height/2));
    auto parent = Node::create();
    addChild(parent);
    parent->addChild(Sprite_all_side_connector); 

but im getting exception , when i remove the SpriteBatchNode every thing working fine .
i want to use the SpriteBatchNode feature for OpenGL one draw call .

I am sorry. What’s your problem?

It seems umen tries to add ‘Sprite_all_side_connector’ as a child twice: to ‘batch’ and to ‘parent’, which is not possible for sure.

The solution is , i only can add the parent to the batch node
and not add it to the layer.
and all its children will be added automatically to the batch node.
am i right ?

A node can only have one parent. So it can not be added twice.

and all its children will be added automatically to the batch node.

Yes. You are right.