void HelloWorld :: SetSpriteParent (CCSprite * pSprite, CCNode * pNewParent, int nZOder, int nTag)
{
if (pSprite-> getParent ()! = NULL)
{
printf ("tag% d remove child tag% d \ n", pSprite-> getParent () -> getTag (), pSprite-> getTag ());
pSprite-> removeFromParentAndCleanup (false);
}
pNewParent-> addChild (pSprite, nZOder, nTag);
}
First delete the original parent wizard, and then addChild
Ball in the air, my father set the ball wizard is the background image, the ball to another player, I set the ball wizard is the athlete's parent
However, the implementation of CCNode :: addChild pop mistake:
CCAssert (child-> m_pParent == NULL, "child already added It can't be added again.");
May I ask how to solve?
Or so I designed is wrong: The ball is bouncing up and down has to be, athletes move when the ball should move and bounce up and down the same, if addChild moved automatically control these
Reply:
Of course, the same can not be added more than once, you can look CCBantchNode, seems to be such a fight of it in the afternoon to go home I look.
Reply:
CCSpriteBatchNode do you mean? It is very much a wizard to add only need to optimize use of it, and my basketball athlete as a child to a different Node does not matter, right?
Reply:
UP ~ ah ~ Come experts confused the issue for two weeks, and the project does not go
Reply:
Reply:
http://www.cnblogs.com/cocos2d-x/archive/2012/02/27/2370167.html
No comments:
Post a Comment