//这里的重点是girl应该怎样才能在boy做完action后执行她的动作呢?有以下几种办法 //1、用延迟的DelayTime来实现,也就是boy运动完后延迟几秒,然后让girl运动 //延迟2.5s,用1s时间跳了3次,跳跃高度100像素,并且向右移动了30像素 girl->runAction(Sequence::create(DelayTime::create(2.5f),JumpBy::create(1.0f,Point(30,0),100,3),NULL)); //2、用回调函数实现,当boy完成后,写一个lambda表达式来实现girl要做的动作(lambda表达式的使用可以参考我上一篇博客) boy->runAction(Sequence::create(RotateBy::create(1.0f,360),ScaleTo::create(1.0f,1.2f), CallFunc::create([=]() { //用1s时间跳了3次,跳跃高度100像素,并且向右移动了30像素 girl->runAction(JumpBy::create(1.0f,Point(30,0),100,3)); }),NULL)); //3、用现成的接口TargetedAction(); auto jump = JumpBy::create(1.0f,Point(30,0),100,3);//先写一个跳跃的动作 auto targetAct = TargetedAction::create(girl,jump);//写一个目标动作,将动作执行人girl和要执行的动作jump放入其中 //将girl的目标动作放入boy的sequence里去 boy->runAction(Sequence::create(RotateBy::create(1.0f,360),ScaleTo::create(1.0f,1.2f),targetAct,NULL));