Hello,
I’m doing a game and I’m using multiple sprites to generate the PJ face. I have one sprite with the face, other with the eyes and another with the mouth and I’m making mouth and eyes children of face like this:
Sprite *face = Sprite::createWithSpriteFramecreate("hero/mouth.png");
eyes = Sprite::create("hero/eyes.png");
eyes->setPosition(30, 35);
face->addChild(eyes, 1, "eyes");
mouth = Sprite::create("hero/mouth_normal.png");
mouth->setPosition(30, 15);
face->addChild(mouth, 1, "mouth");
This works like a charm, I can generate a Sprite with multiple Sprites as children. Now I need to clone this Sprite to duplicate the face and I couldn’t find a solution… I found this:
First Try
Sprite *duplicated_face = Sprite::createWithSpriteFrame(face->getSpriteFrame());
The children sprites are not copied into the new duplicated_face sprite
Second Try
Sprite *duplicated_face = Sprite::createWithTexture(face->getTexture());
Here I got exactly the same issue, the children are not copied to the parent…
I also looked for some method to clone a Sprite but couldn’t find anything useful.
Any help would be appreciated