关于CCNode 中的addChild函数

引擎TestCpp中的NodeTest样例中"anchorPoint and children"
源代码有test2:onEnter函数为什么不能做如下修改:

CCSprite *sp1 = CCSprite::create(s_pPathSister1);
CCSprite *sp2 = CCSprite::create(s_pPathSister3);
CCSprite *sp3 = CCSprite::create(s_pPathSister4);
sp1->setPosition(ccp(100, s.height /2 ));
addChild(sp1);
sp1->addChild(sp3); //可以看到sp3跟随sp1运动。
sp2->addChild(sp4); //但编译执行后却看不到sp4???

没有addChild(sp2);吗?sp4又是哪定义的?

代码好歹写完整点

不好意思。我的意思是把最后一句改成 sp3->addChild(sp2); //但编译执行后却看不到sp2???

— Begin quote from ____

引用第2楼thomugo于2014-04-12 14:26发表的 回 1楼(孤独の快乐) 的帖子 :
不好意思。我的意思是把最后一句改成 sp3->addChild(sp2); //但编译执行后却看不到sp2??? http://www.cocoachina.com/bbs/job.php?action=topost&tid=197814&pid=925259

— End quote

你到底是看不到谁了·····

你sp2坐标多少?

我真不知道你到底改多少了

就把最后一行改了就行。
sp2跟sp3不用设坐标的。我是想问问什么sp2不能像sp3加入到精灵sp1中那样加入到sp3中。从而得到3个精灵做同样动作的效果?

— Begin quote from ____

引用第4楼thomugo于2014-04-12 14:42发表的 :
就把最后一行改了就行。
sp2跟sp3不用设坐标的。我是想问问什么sp2不能像sp3加入到精灵sp1中那样加入到sp3中。从而得到3个精灵做同样动作的效果? http://www.cocoachina.com/bbs/job.php?action=topost&tid=197814&pid=925269

— End quote

你能把你整个onEnter发出来吗

void Test2::onEnter()
{
TestCocosNodeDemo::onEnter();

CCSize s = CCDirector::sharedDirector()->getWinSize();

CCSprite *sp1 = CCSprite::create(s_pPathSister1);
CCSprite *sp3 = CCSprite::create(s_pPathSister1);
CCSprite *sp4 = CCSprite::create(s_pPathSister2);

sp1->setPosition(ccp(100, s.height /2 ));

addChild(sp1);

sp1->addChild(sp3);
sp3->addChild(sp4);    


CCActionInterval* a1 = CCRotateBy::create(2, 360);
CCActionInterval* a2 = CCScaleBy::create(2, 2);

CCAction* action1 = CCRepeatForever::create( CCSequence::create(a1, a2, a2->reverse(), NULL) );


sp1->runAction(action1);

}

— Begin quote from ____

引用第6楼thomugo于2014-04-12 14:54发表的 :
void Test2::onEnter()
{
TestCocosNodeDemo::onEnter();

CCSize s = CCDirector::sharedDirector()->getWinSize();

http://www.cocoachina.com/bbs/job.php?action=topost&tid=197814&pid=925273

— End quote

该代码测试完毕,没问题啊,确实是三个精灵做同样的动作