void Test2::onEnter() { TestCocosNodeDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCSprite *sp1 = CCSprite::create(s_pPathSister1); CCSprite *sp2 = CCSprite::create(s_pPathSister2); CCSprite *sp3 = CCSprite::create(s_pPathSister1); CCSprite *sp4 = CCSprite::create(s_pPathSister2); sp1->setPosition(ccp(100, s.height /2 )); sp2->setPosition(ccp(380, s.height /2 )); addChild(sp1); addChild(sp2); sp3->setScale(0.25f); sp4->setScale(0.25f); //把sp1和sp2当做父节点 sp1->addChild(sp3); sp2->addChild(sp4); CCActionInterval* a1 = CCRotateBy::create(2, 360); CCActionInterval* a2 = CCScaleBy::create(2, 2); CCAction* action1 = CCRepeatForever::create( (CCActionInterval*)(CCSequence::create(a1, a2, a2->reverse(), NULL)) ); CCAction* action2 = CCRepeatForever::create( (CCActionInterval*)(CCSequence::create( (CCActionInterval*)(a1->copy()->autorelease()), (CCActionInterval*)(a2->copy()->autorelease()), a2->reverse(), NULL) ) ); sp2->setAnchorPoint(ccp(0,0)); //直接对父节点执行动作,子节点也会跟着执行 sp1->runAction(action1); sp2->runAction(action2); }